1234567891011121314151617181920212223242526272829 |
- package J20250725;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- /**
- * @author WanJl
- * @version 1.0
- * @title Demo09_FileReader
- * @description
- * @create 2025/7/25
- */
- public class Demo09_FileReader {
- public static void main(String[] args) throws IOException {
- FileReader fr=new FileReader("D:/我的文件.txt");
- int ch;
- // while ((ch=fr.read())!=-1){
- // System.out.print((char)ch);
- // }
- char[] chars=new char[1024];
- int length;
- while ((length=fr.read(chars))!=-1){
- System.out.println(new String(chars,0,length));
- }
- fr.close();
- }
- }
|