//字符的方式读取txt
BufferedReader reader=new BufferedReader(new FileReader("d://t.txt"));
String line="";
while((line=reader.readLine())!=null){
System.out.println(str);
}
//字节的方式读取txt
BufferedInputStream in=new BufferedInputStream(new FileInputStream("d://t.txt"));
BufferedOutputStream out=new BufferedOutStream(new FileOutInputStream("d://tt.txt"));
byte[] buff=new byte[1024]; int hasRead=0;
while((hasRead=in.read(buff,0,1024))!=-1){
out.write(buff,0,hasRead);
out.flush();
}
//写txt
String str="welcome to china";
byte[] buff=new byte[255];
buff=str.getBytes();
OutputStream out=new OutputStream(new File("d://t3.txt"));
out.write(buff,0,buff.length);
out.flush();