String path = "D:\\dome.txt"; //文件路径
File file = new File(path);//生成文件对象
FileWriter fw = new FileWriter(file,true);//true 写进去的内容不覆盖原先的内容,false 覆盖
String ss = "hgkdhgk";
fw.write(ss);//把内容写进去
System.out.println("-----------");
FileReader fr = new FileReader(file);
char[] c = new char[1024];//字符数组容器
while(fr.read(c)>0){//讲读取的内容放在字符容器中,并返回读取的大小
System.out.print(c);
}
BufferedReader br = new BufferedReader(fr);
System.out.println(br.readLine());//读取一行
BufferedWriter bw = new BufferedWriter(fw);
bw.write("jdfhdjhgjhgj");//把内容写进去
字符流
最新推荐文章于 2023-06-13 19:18:58 发布