//Sample04_03.java import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.UnsupportedEncodingException; import java.io.FileNotFoundException; import java.io.IOException; class Sample04_03{ public static void main(String[] args){ String path = "hello.txt"; File file = new File(path); StringBuilder strb = null; try { BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream(file), "UTF-8" ) ); strb = new StringBuilder(); String strLine; while((strLine = br.readLine()) != null) { strb.append(strLine); strb.append("\n"); } br.close(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e){ e.printStackTrace(); } if(strb!=null){ System.out.println(strb.toString()); }else{ System.out.println("null"); } } }