Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.io.*;
  2. public class CharCodingDemo {
  3.  
  4.     public static void main(String[] args) throws IOException {
  5.         String sentence = "你好嗎?";
  6.         byte[] src = sentence.getBytes();
  7.         FileOutputStream fos = new FileOutputStream(new File("chinese.txt"));
  8.         fos.write(src);
  9.         fos.flush();
  10.        
  11.         FileInputStream fis =new FileInputStream("chinese.txt");
  12.         InputStreamReader isr = new InputStreamReader(fis, "latin1");
  13.         BufferedReader br =new BufferedReader(isr);
  14.         System.out.println(br.readLine());
  15.     }
  16. }