import java.io.BufferedReader;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.InputStreamReader;

 

public class TextFileReader

{

       public static void main(String[] args)

       {

             File file = new File("C:/test.txt");

             InputStreamReader input;

             FileInputStream fis;

             BufferedReader br;

            

             try

             {

                    fis = new FileInputStream(file);

                    input = new InputStreamReader(fis, "UTF-8");

                    br = new BufferedReader(input);

                   

                    int data=0;

 

                    while((data=br.read()) != -1)

                    {

                           System.out.print((char)data);

                    }

                    System.out.println();

                    fis.close();

             }

             catch (FileNotFoundException e)

             {

                    e.printStackTrace();

             }

             catch (IOException e)

             {

                    e.printStackTrace();

             }

 

       }

}


저작자 표시 비영리 변경 금지
신고
YOUR COMMENT IS THE CRITICAL SUCCESS FACTOR FOR THE QUALITY OF BLOG POST