Io 读写text 文件一体化
package Io;
import java.io.*;
public class F {
public static void main(String[] args) throws IOException {
F a =new F();
a.b();
//写文件
try {
FileWriter f =new FileWriter("D:\\rund.text");
f.write("asdadadad");
f.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//读文件
public void b() throws IOException{
FileReader fr =new FileReader("D:\\rund.text");
char [] arr =new char[1024];
int data=0;
while((data=fr.read(arr))!=-1)
{
//把数据查出来
System.out.println(new String(arr,0,data));
}
}
}