ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 버퍼 한글 출력
    TIL(today i learned)/java 2020. 9. 10. 23:25
    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
    27
    28
    29
    30
    31
    32
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
     
    public class buffer_stream {
        public static FileReader FR=null;
        @SuppressWarnings("resource")
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            File root=new File("C:\\Temp\\test2.txt");
            try {
                FR=new FileReader(root);//버퍼가 5를 넘어가면 5까지 출력
                BufferedWriter BF=new BufferedWriter(new OutputStreamWriter(System.out,"utf-8"),5);//크기가 5인 버퍼를 만듬
                int c;
                while ((c=FR.read())!=-1) {
                    BF.write((char)c);
                    
                }//5까지만 버퍼를 출력
                //new Scanner(System.in).nextLine();//.엔터누르면 남아잇는 버퍼 모두출력 이제 이 Scanner 객체를 지정할수없음 일회용임 다시말해 닫을 수도없다는 의미 노란줄이 뜨는이유임
                //BF.flush();
                BF.close();
                FR.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();// 오류메세지 출력
            }
        }
     
    }
     
    cs

     

     

    'TIL(today i learned) > java' 카테고리의 다른 글

    ArrayList  (0) 2020.09.12
    EOF와 -1  (0) 2020.09.11
    버퍼  (0) 2020.09.08
    파일 입추력시 줄 바꾸기  (0) 2020.09.04
    스트림 연습  (0) 2020.09.02
Designed by Tistory.