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

Try not to rely upon the default encoding, but define it explicitly.

Similar Messages

  • How to print Chinese character in Zebra printer?

    Hi,
    Could you please advise how to print Chinese in Zebra printer, I have added below ZPL command line in SAPSCRIPT, but it did not work.
    ^CW1,B:MSUNG.FNT
    FO711,60A1N,47,79CI17F8FB1561,3,0,LFN998^FS

    Hi,
    go through the following links.
    [Printing Chinese Characters on Labels using ZEBRA;
    I hope it helps.
    Regards,
    Rohit

  • Report cant print Chinese character properly when direct output to printer

    I have follow the instruction {How to Print PDF/UTF8 in R12? [ID 778970.1]} {PASTA 3.0 Release Information}
    I am able to print the chinese character properly in PDF format. (direct to printer)
    However, some standard report like "Final Payment Register" "TEXT format" NOT able to print chinese character(direct to printer)
    When I preview the report it can display chinese character properly.
    Please advise

    However, some standard report like "Final Payment Register" "TEXT format" NOT able to print chinese character(direct to printer)
    When I preview the report it can display chinese character properly.Please see (What Happened To The Preliminary And Final Payment Register In R12? [ID 746339.1]).
    Thanks,
    Hussein

  • How to print a text in java?

    How to print a text in java?

    of corse, i have JTextField in my frame that i want to extract the text and print it on a paper with a printer.

  • How to Print a Character in Reverse video ...?

    Hi Could any one of you help me " How to print a character in Reverse Video " in SMART Forms and in SAP Scripts.
    Regards,
    Saravanan
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Mar 26, 2009 5:31 PM

    deepak_c3 wrote:
    Thanks for the info.,
    where should the page number n-1-i be returned ?
    Which method implementation of Pageable interface should return the page number ?w.r.t. your first question: don't return that number but return page n-1-i when page i is requested; your document will be printed in reverse order. Your class should implement the entire interface and wrap the original Pageable. (for that number n your class can consult the wrapped interface; read the API for the Pageable interface).
    kind regards,
    Jos

  • How to print PDF files using java print API

    Hi,
    I was goign throw lot of discusion and reading lot of forums related to print pdf files using java api. but nothing seems to be working for me. Can any one tell me how to print pdf files using java api.
    Thanks in advance

    Mike,
    Can't seem to get hold of the example described in your reply below. If you could let us have the URL to get then it would be great.
    My GUI application creates a pdf document which I need to print. I want to achieve this using the standard Java class PrinterJob (no 3rd party APIs I'm afraid, commercial restraints etc ..). I had a stab at it using the following code. When executed I get the pretty printer dialog then when I click ok to print, nothing happens!
    boolean showPrintDialog=true;
    PrinterJob printJob = PrinterJob.getPrinterJob ();
    printJob.setJobName ("Contract.pdf");
    try {
    if (showPrintDialog) {
    if (printJob.printDialog()) {
    printJob.print();
    else
    printJob.print ();
    } catch (Exception PrintException) {
                   PrintException.printStackTrace();
    Thank you and a happy new year.
    Cheers,
    Chris

  • How to put Chinese character in jar file by java.util.jar.Manifest?

    Now I want to develop a simple package tool which can modify some property in manifest.mf of jar files,but the Manifest class's putValue method only can correctly save English character.why?
    And how can I put Chinese character?
    the code is:
    Attributes ab = mf.getMainAttributes();
    ab.putValue("agent-Name", agent);

    Attribute values can contain any character and it will be UTF-8 encoded when written to the manifest, according to Javadoc.
    What makes you think that this mechanism fails? What do you see instead of the Chinese character? And what tool/editor/program you use to see it? I did not try myself, but according to the Javadoc there should be no problem.

  • Cannot print Chinese character in postscript 11iAS

    We are using HRMS 11.5.10AS.
    We want to print the report in postscript. However, some chinese character cannot be print correctly. ( it's right in TXT )
    Anyone know how to solve it?

    chulongjiang,
    i solve the problem with your advice, thanks lot!
    Regards,
    Alan 24/11/2005

  • How to print  Excel file in java?

    Hi, all
    I had written a program to generate a Report with Excel in java using the jexcelapi_2_5_7 . But I don't know how to print it in java program. It seems that java print Service don�t support Excel flavor. How should I do? It will be a great appreciate for me if anyone could help me.
    Regards
    David

    Hi ,
    i m asking if you got a solution for your problem ;
    i need solution to the same problem
    thx in advance

  • How to print chinese web page with netscape browserver in Solaris 9 OS ?

    Dear All,
    I would like to print chinese web page within netscape browser in Solaris 9 Traditional Chinese OS, the print out result is garbage code on the paper not correctly chinese fonts.
    I can print out correctly the chinese document create by StarSuite 7.0 on Solaris 9 OS environment and also the chinese web page is correctly display within Netscape browser but for printing is abnomal result.
    Can someone point me to how to do print chinese web page with browser in Solaris 9 environment ?
    Best Regards,
    -- Kuo

    hi
    i have encountered this problem before and i remember downloading some fonts package and installing it. u could google search your question and it should provide the solution.thats how i stumbled upon the package.
    cheers,
    bunny

  • How to type chinese character in Oracle Report builder 6i?

    Hi,
    Does anyone know how to include the chinese character in the rdf file under Oracle Report Builder 6i?

    Hi,
    please check with this link
    [https://blogs.oracle.com/ankitkaushik/entry/displaying_multilingual_data_i ]
    Hope this link will help you
    Thanks & Regards,
    pallis

  • How to print a Pdf from Java script

    Hi,
    I need to print a pdf from java script. In java script i have url of pdf. Is there any way to print pdf from java script?
    I am able to print word doc by ActiveX. is there any activeX or something else which do the same thing for pdf?
    Any help heartily esteemed to me.
    Thanks
    Kamlesh Sharma

    you are cross postin .. your thread has been answered in the jsp jstl forums

  • How to print the table in java.

    we want to take the print out of JTable in java.
    But we have some other components on the GUI
    alongwith the JTable.Now our query is that how cud
    we take the print out of JTable only?
    we are using jdk1.4.2 version of java.In this version
    we don't have any direct method of taking the print out
    of JTable.
    Any valuable suggestion will be appreciated.
    Thanks.

    You don't have to use a reporting tool:
    http://java.sun.com/docs/books/tutorial/2d/printing/in
    dex.html
    Okie! Thats only a suggestion. Im sorry.

  • How to print a JTable  in Java Swing ?

    Hi,
    I have an application written in java swing.Now I want to write a print module that prints some details.The details includes the JTextArea and JTable that changes in size dynamically.One solution i found is to put them in a panel and print that panel.But it is static.The size of JTable and JTextArea changes, according to the given input.Please give me a solution for this.

    Printing is a bit of a nightmare, actually. Most of the trouble is layout. Basically a Printable is passed a page number and a graphics context and has to work out what components go on that page and where. It can't depend on the pages being requested in sequence.
    You can call getPrintable from a JTable, and you can call that through your own Printable in order to add extra pages. However you can't ask a Printable how many pages it's going to produce, you just have to invoke it and see if it returns a code to say that the page is out of range.
    And the Printable JTable generates is very limited, the table has to occupy full pages, you can't tell it to start in a different place on the first page, or find out how much space it's used on the last page. The headers and footers generate JTable's own idea of a page number, not yours.
    You can call print() on most Swing components, but you'll need to set their size and location first, and/or mess with the transformation in the graphics context.

  • How to print a page in java ??

    Hi,
    i want to know how, after pushing a button, display the printer dialog box and then print the content of a JDialog box ??
    If you have a link for documentation, it will be great.
    Thanks in advance
    Steve

    That's how you display the Printdialogbox and startt the Printjob!
    try {
         PrinterJob prnJob = PrinterJob.getPrinterJob();
         prnJob.setPrintable(this);
         if ( !prnJob.printDialog() )
              return;
         prnJob.print();
    } catch (Exception e ){
         e.printStackTrace();
         System.err.println("Printing err :" + e.toString() );
    Your dialog must implement the Printable Interface. So you must implement the print(...) method. Here you draw the Graphics Object how you want your output to the printer.
    This question of the weeks con give you more Information.
    http://developer.java.sun.com/developer/qow/archive/30/index.html
    Bye
    Jonas

Maybe you are looking for

  • Airport not connecting

    Having a problem with my airport, cannot connect to the internet wirelessly. It is not a distance problem as a laptop sitting right next to it registers three out of five bars and works perfectly. Been having this problem for several months, at first

  • What is install Error 1327?

    I'm a totall newbie at 4GLs in general and Java in particular and I can't even install the JRE !!! I downloaded the j2re-1_4_2_09 pack and ran it and the machine - P3 1000, 256 MB RAM, Win 98 SE, BTW - kept saying "Error 1327 Invalid drive E:\" I don

  • Connect by prior statement....

    Hi, please help me in the following query. select a.part,a.assy from assy_info a connect by prior part = assy start with assy in ('A'); part assy B A C B Z C H Z I don't want the above query to extract after part = 'Z'. please help me... regards laxm

  • Missing applications folder, gone hidden & need help!

    This is the second time this has happened to me and someone did tell me how to fix this but I have since forgotten. I'm hoping someone here can remind me. I've got an eMac running 10.4.10 and when I open the Finder window, the applications folder is

  • Hi all..very urgent

    Hi Gurus, Could you plz help me to collect the tables, structures,views, search helps and programs which uses PRODH3 and PRODH4 data elements... plz guys very urgent.. marks wud definetly be given. Regards Sahil