1.字符输出流(PrintWriter)
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Dome10 {
public static void main(String[] args) {
BufferedReader br = null;
PrintWriter pw = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream("d:/a.txt")));
pw = new PrintWriter("d:/c.txt");
String temp = "";
int i = 1;
while ((temp = br.readLine()) != null) {
pw.println(temp);
i++;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (br != null) {
br.close();
}
if (pw != null) {
pw.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
![]()