how to read big5 files in Java


/*
  ReadBig5File.java
  
    read a file in big5 code
  
  > javac ReadBig5File.java
  > java ReadBig5File big5.txt
  Big5編碼文字檔
*/
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class ReadBig5File
{
  public static void main(String args[]) throws
    java.io.FileNotFoundException,
    java.io.UnsupportedEncodingException,
    java.io.IOException
  {
    String file="big5.txt";
    FileInputStream fis = new FileInputStream(new File(file));
     // java.io.FileNotFoundException
    BufferedReader br =new BufferedReader(new InputStreamReader(fis,"BIG5"));
     // java.io.UnsupportedEncodingException
    
    // java.io.IOException
    while(br.ready())
    {
      String line=br.readLine();
      System.out.println(line);
      System.out.flush();
    }
    br.close();
  }
}

沒有留言:

choose which S3 object ownership?

S3 Object Ownership 兩種模式差異 Amazon S3 服務全名為 簡單儲存服務 (Simple Storage Service),可支援存取放置於AWS公有雲的檔案,其服務類似 Google Drive 或 Microsoft OneDrive 的網碟功能...

總網頁瀏覽量