reading text file with utf-8 encoding using java

CASE 1.

PrintStream out =newPrintStream(System.out,true,"UTF-8");
out.println(str);


CASE 2.
import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.UnsupportedEncodingException;publicclass test {publicstaticvoid main(String[] args){try{File fileDir =newFile("PATH_TO_FILE");BufferedReader in =newBufferedReader(newInputStreamReader(newFileInputStream(fileDir),"UTF8"));String str;while((str = in.readLine())!=null){System.out.println(str);}

            in.close();}catch(UnsupportedEncodingException e){System.out.println(e.getMessage());}catch(IOException e){System.out.println(e.getMessage());}catch(Exception e){System.out.println(e.getMessage());}}

}