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();
  }
}

沒有留言:

Building a Lightweight Streamlit Client for Local Ollama LLM Interaction

Ollama 提供端點串接服務,可由程式管理及使用本地大語言模型(LLM, Large Language Model)。 以下程式碼展示如何以 Streamlit 套件,建立一個輕量級的網頁介面,供呼叫 本地端安裝的 Ollama 大語言模型。 Ollama 預設的服務...

總網頁瀏覽量