标签:writer null 文件 input 小结 i/o output puts while
1 读写字符文件
BufferedReader br = new BufferedReader (new FileReader("文件路径"));
BufferedWriter br = new BufferedWriter (new FileWriter("文件路径",boolean));
2 读取字节文件
DataInputStream dis = new DataInputStream(new FileInputStream("文件路径"));
DataOutputStream dis = new DataOutputStream(new FileOutputStream("文件路径"));
3 读取整个字符文件
String str = null;
while((str=br.readLine())!=null){
System.out.println(str);
}
4读取整个字节文件
int b;
while((b=dis.read())!=-1){
System.out.println(b);
}
标签:writer null 文件 input 小结 i/o output puts while
原文地址:http://www.cnblogs.com/yangchan250/p/6835682.html