12.字符输出流(PrintWriter )
作者:互联网
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();
}
}
}
}
标签:字符,12,java,pw,io,PrintWriter,br,null 来源: https://www.cnblogs.com/lyq888/p/16132419.html