코딩의 숲 2020. 9. 11. 12:31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.io.FileReader;
import java.io.IOException;
 
public class buffer_stream_move {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        try {
            FileReader fr=new FileReader("C:\\windows\\system.ini");
            char []buf=new char[1024*2];
            while (true) {
                int n=fr.read(buf);
                System.out.println(buf);
                System.out.println(n);
                if(n<buf.length)
                    break;
            }
            
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
 
}
 
cs

에서 n은 eof을 만났을떄 -1을반환한다