11.用FileInputStream和FileReader来读取文本文件的区别
2017-07-10 22:07
197 查看
11.用FileInputStream和FileReader来读取文本文件的区别
可以用记事本打开的,可以看懂的,就适合用字符流来处理.
字节流
InputStream and outputstream
fileinputstream and fileoutputstream
通过fileinputstream来读取文本文件,显示在屏幕上
输出结果为:
13 10 1……..
可以用记事本打开的,可以看懂的,就适合用字符流来处理.
字节流
InputStream and outputstream
fileinputstream and fileoutputstream
通过fileinputstream来读取文本文件,显示在屏幕上
输出结果为:
13 10 1……..
package javastudy; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import com.sun.org.apache.bcel.internal.generic.NEW; public class Test1 { public static void main(String[] args) throws IOException { //*************1****************** // FileInputStream fis=new FileInputStream("I:\\001 学习\\003 java\\Java入门第四季\\11.用FileInputStream和FileReader来读取文本文件的区别\\11.用FileInputStream和FileReader来读取文本文件的区别.txt"); // int ch=0; // while((ch=fis.read())!=-1) // { // System.out.print((char)ch+"\t"); // } //*************2****************** // int len=fis.available(); // byte[] data=new byte[len]; // fis.read(data); // System.out.println(new String(data)); // fis.close(); //*************3****************** FileReader fr=new FileReader("I:\\001 学习\\003 java\\Java入门第四季\\11.用FileInputStream和FileReader来读取文本文件的区别\\11.用FileInputStream和FileReader来读取文本文件的区别.txt"); int ch=0; while((ch=fr.read())!=-1) { System.out.print((char)ch); } fr.close(); } }
相关文章推荐
- 案例 1-4: 用 FileReader 读取文本文件
- File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别
- FileInputStream与BufferedInputStream、FileInputStream与FileReader区别
- Java FileInputStream与FileReader的区别
- FileInputStream与BufferedInputStream、FileInputStream与FileReader区别
- File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别
- [转]Java FileInputStream与FileReader的区别
- File、FileInputStream及FileReader的区别
- BufferedReader、FileReader、FileInputStream的区别
- FileInputStream和FileReader的区别
- FileInputStream和FileReader的区别
- BufferedReader、FileReader、FileInputStream的区别(转)
- FileInputStream与FileReader读取文件
- BufferedReader、FileReader、FileInputStream的区别
- Java,IO之FileInputStream和FileReader读取文件(疯狂java讲义)
- BufferedReader、FileReader、FileInputStream的区别
- File,FileInputStream,FileReader,InputStreamReader,BufferedReader的使用和区别
- File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别
- Java笔记--File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别
- FILE,FILEINPUTSTREAM,FILEREADER,INPUTSTREAMREADER,BUFFEREDREADER的使用和区别