How to print Chinese character in java
Hi All,
I have a problem .
I am trying to read a file which contains chinese characters and the print the content of this file to the printer.
But when the content of the file is being printed, it is printing weird characters and not chinese characters. Can anyone please help.
Plese find below, my code.
import java.io.*;
import java.lang.*;
import java.io.BufferedInputStream;
class FileRead{
//--< main >--//
public static void main (String[] args) {
FileRead t = new FileRead();
t.readMyFile();
}
//--< readMyFile >--//
void readMyFile() {
String record = null;
int recCount = 0;
try {
FileReader fr= new FileReader("amaebisushi.GB.TXT");
FileOutputStream os = new FileOutputStream("\\\\ps_apex_1\\ps_lpt1");
BufferedReader br = new BufferedReader(fr);
PrintStream ps2 = new PrintStream(os);
record = new String();
while ((record = br.readLine()) != null) {
recCount++;
System.out.println(recCount + ": " + record);
ps2.println(recCount + ": " + record);
}
} catch (IOException e) {
// catch possible io errors from readLine()
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
}
} // end of readMyFile()
} // end of class

