标签:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Test05 {
public static void main(String[] args) throws FileNotFoundException {
FileReader fis = new FileReader("D:\\新建文件夹\\莫负相遇.txt");
BufferedReader br = new BufferedReader(fis);
//为什么没用数组
String input = null;
try {
while ((input = br.readLine()) != null) {
System.out.println(input);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class Test06 {
public static void main(String[] args) throws IOException {
FileWriter fw=new FileWriter("D:\\新建文件夹\\ccc.txt");
BufferedWriter bw=new BufferedWriter(fw);
//为什么不需要String
bw.write("我爱北京天安门,天安门上太阳升");
bw.flush();
fw.close();
System.out.println("录入成功");
}
}
标签:
原文地址:http://www.cnblogs.com/zqsheng/p/5200686.html