Java - Print Chinese from UTF-8 code

By xngo on June 30, 2019

import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
 
public class PrintChinese {
 
    public static void main(String[] args) throws UnsupportedEncodingException {
        String chineseString = "\u4e00\u4e01\u4e02\u4e03\u4304";
        System.out.println(chineseString);
        PrintStream ps = new PrintStream(System.out, true, "UTF-8");
        ps.println(chineseString);
    }
}

Output

一丁丂七䌄
一丁丂七䌄

Github

  • https://github.com/xuanngo2001/java-small/blob/master/src/net/openwritings/java/io/PrintChinese.java

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.