- public static void main(String[] args) throws Exception {
-
- File f = new File("C:\\1.txt");
-
- OutputStream os = new FileOutputStream(f);
-
- os.write("abasdfgasdfcde".getBytes());
- os.close();
-
- Reader r = new FileReader(f);
- char[] chars = new char[1024];
- int len = 0;
- while((len = r.read(chars))==0){
- return;
- }
- System.out.println(new String(chars,0,len));
- r.close();
- }
复制代码
这样可以吗?只要被读取的文件是字符型的,就可以用FileReader读取吧
|