How to write to file Unicode characters

I have PDF files that I need to copy some strings out of and put them in various fields in a Postgres database. The goal is a Java screen into the database, whiere I mark and copy the PDF text and then paste it into a field in a Swing window, and from there into the database.
I am unsuccessful at reading a PDF file, so I have opted to cut and paste the PDF file into an MS word file. This results in errors in certain unicode characters. I am trying to rectify them by a simple program, a start of which is below, by a replacement of the erroneous char by the proper unicode symbol. As, shown by the following, I cannot figure out how to write out a unicode character. Do I need to wrap (which I don't know much about yet)? Or do I have a file problem? (I have a Vista machine.) I don't think it should be impossible to write unicode into a file, as I am able to write into MS Word files phonological symbols, Russian, and Sanskrit. So, it must be in the java.
P.S.: I am reading Schildt's Java: A Beginner's Guide and am through chapter10, but remaining chapters are on threads, enumerations, autoboxing, static import, annotations; generics,; applets, events, and miscellaneous topics, and, finally Swing. Maybe its in the autoboxing?
Any help would be most appreciated.
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;
public class CopyCharacters {
public static void main(String[] args) throws IOException {
FileReader inputStream = null;
//FileWriter outputStream = null;
PrintWriter outputStream = null;
     char longa = 0x0101;
     int longc = 0x0101;
     char capA = 0x0041;
     char longb = 0x0111;
// Unicode for uppercase Greek omega character char uniChar = '\u039A'
     char uniChar = '\u039A';
// Character ca = new Character('0x0101'); // illegal
     Character cb = new Character('\u0101');
     Character cc = '\u0101';
int c;
try {
inputStream = new FileReader("Cardona1.txt");
outputStream = new
               PrintWriter(new FileWriter(
                    "characteroutput.txt"));
          outputStream.println( "character1 " + capA); //yields A
          outputStream.println( "character2 " + longa); //yields ?
          outputStream.println( "character3 " + '\u0101'); //yields ?
          outputStream.println( "character4 " + longc); //yields 257
          outputStream.println( "character5 " + "S\u00ED Se\u00F1or"); // yields character Sí Señor
          outputStream.println( "character6 " + "S'\u00ED' Se\u00F1or"); // yields S'í' Señor
          outputStream.println( "character7 " + "S\u0121 Se\u00F1or"); // yields character S? Señor
          outputStream.println( "character8 " + "S'\u0121' Se\u00F1or"); // yields character S'?' Señor
          outputStream.println( "character9 " + uniChar);// yields character ?
          outputStream.println( "character10 " + '\u00FF');// yields character ÿ but fails on \u0100.
// only 0-255!!
          outputStream.println( "character11 " + cc);// yields ?
          outputStream.println( "character12 " + cb);// yields ?
          outputStream.println( "character13 ?");// yields ?
while ((c = inputStream.read()) != -1) {
     // outputStream.writeln(c);- error
} finally {
if (inputStream != null) {
inputStream.close();
if (outputStream != null) {
outputStream.close();
}

I am unsuccessful at reading a PDF file, so I have opted to cut and paste the PDF file into an MS word file. This results in errors in certain unicode characters.Stop right there. You are digging a hole. Stop digging. Fix the problems with reading the PDF file.

Similar Messages

  • How to write WSDD file to deploy web service

    I write a server code,I want to deploy it as service,but I don't know how to write WSDD file?I use AXIS and SOAP
    I need help,thanks a lot.
    Regards
    William
    2.24

    Yes, put your wsdd with your class files. But if you want AdminClient to work correctly, be sure all environement variables are set correctly.
    Me, I never use it, I prefer to modify directly the server-config.wsdd

  • How to write a file using mod pl/sql

    hi,
    i am having a submit button in my procedure. which should inturn create .sql file in a file path.
    is there any way to create a fileusing htp and htf methods.
    Thanks in advance
    Hari

    >
    i am having a submit button in my procedure. which should in turn create .sql file in a file path.
    is there any way to create a file using htp and htf methods.
    >
    Why are you wasting your time coding from scratch using the PL/SQL Web Toolkit instead of the APEX framework?
    From Re: how to write a file using mod pl/sql it appears that you are not using APEX, so a number of the approaches APEX offers are not relevant. You appear to be looking for a file download solution using the <tt>wpg_docload.download_file</tt> method, such as:
    create or replace procedure download_file (
        p_filename  in     varchar2
      , p_mimetype  in     varchar2
      , p_content   in out nocopy blob)
    is
    begin
      -- Set up HTTP header.
      -- Use "application/octet" as default MIME type.
      owa_util.mime_header(nvl(p_mimetype, 'application/octet'), false);
      -- Set the size so the browser knows how much to download.
      htp.p('Content-length: ' || dbms_lob.getlength(p_content));
      -- Filename will be used as default by the browser in "Save as..."
      htp.p('Content-Disposition: attachment; filename="' || p_filename || '"');
      -- Close header.
      owa_util.http_header_close();
      -- Stream the file content to the browser.
      wpg_docload.download_file(p_content);
    end download_file;

  • How to write text file in Shockwave?

    Does anybody know how to write text file in Shockwave to
    user's disk?
    Thanks in advance.

    Those Xtras can wreak to much havoc when used with the wrong
    intent.
    What you can do is write with setpref and store a list of
    saves and the
    saves itself seperatly. Then you'd have to build your own
    save/open
    dialog to let the user:
    * pick a previously saved file to load or overwrite
    * have the user type the name of a new file to save.
    Only thing that remains is that the user cannot decide where
    the files
    are saved.
    Manno
    SiuLinda wrote:
    > Thanks a lot for your reply.
    > Yes, cookies is good but I have to write a program to
    save the text file in
    > where the user wants, user can open these files later if
    they like, like using
    > Filextra and Fileio, but I found all of these xtras seem
    to be not supported in
    > shockwave.
    >
    Manno Bult
    [email protected]

  • How to write certain file On jCD through Java

    hi all,
    I got big problem in java , would anybody tell me how to write certain file onto CD through java. Is there any API available for this.
    Thanks in advance
    --Harish                                                                                                                                                                                                                                                                                                                                                               

    You might check this thread.
    http://forum.java.sun.com/thread.jspa?threadID=212748&tstart=90

  • URGENT : Viewing HTML files & UNICODE characters

    I do not know how to view HTML files in Java2. I have various HTML files which I would just like to display in the ContentPane of a Dialog Box.
    Please let me know how should I do it.
    Also, I have another question. How do I display Unicode characters like the alpha and the beta even after I know their hexadecimal values? I would like to display them as text on a JLabel. But the intended character doesnt appear. Instead, what appears is a black empty square in its place. Please let me know how to rectify this.

    You can use JEditorPane to display HTML file.You can dislpay alpha and the beta characters by
    jlabel.setText("\u03B1\u03B2");
    where 03B1 is unicode value for alpha and 03B2 is unicode value for beta.
    You can get unicodes for Greek from following link.
    http://www.unicode.org/charts/PDF/U0370.pdf

  • How to send non-latin unicode characters from Flex application to a web service?

    Hi,
    I am creating an XML containing data entered by user into a TextInput. The XML is sent then to HTTPService.
    I've tried this
    var xml : XML = <title>{_title}</title>;
    and this
    var xml : XML = new XML("<title>" + _title + "</title>");
    _title variable is filled with string taken from TextInput.
    When user enters non-latin characters (e.g. russian) the web service responds that XML contains characters that are not UTF-8.
    I run a sniffer and found that non-printable characters are sent to the web service like
    <title>����</title>
    How can I encode non-latin characters to UTF-8?
    I have an idea to use ByteArray and pair of functions readMultiByte / writeMultiByte (to write in current character set and read UTF-8) but I need to determine the current character set Flex (or TextInput) is using.
    Can anyone help convert the characters?
    Thanks in advance,
    best regards,
    Sergey.

    Found tha answer myself: set System.useCodePage to false

  • Hi how to write text file continuosly

    hi i know how to write a text file but if i write something and close the
    whole program, then when i open the program and do the samething,
    i wanna write something contiguosly, write the next line of the very last saved line..
    but..i tried couple of times,but the written sentence just overlapped,,,and
    can't write continuously,,,
    how to solve it............

    Are you saying you want to create a file the first time you run a program, and append to the file the second time? If so, check the constructors for the class you are using to write the file. There should be one that takes a boolean flag telling it you want to append instead of overwrite. Set the flag to true.
    For example:
    http://java.sun.com/j2se/1.5.0/docs/api/java/io/FileWriter.html#FileWriter(java.lang.String, boolean)FileWriter(String fileName, boolean append)
    Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written.

  • How to write a file in unix server through oracle plsql code

    Hi All,
    My requirement is to create and write a file (any file for eg txt file) in unix box with in a specified directory through oracle plsql code.
    Oracle sits in windows server.
    using utl_file package we can create directory where oracle resides and write it there in oracle server in our case windows..
    But here we need to create,write a file but in unix server which is different server than where the oracle server resides..
    we are using Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    Can any one one please help me out in this issue...
    Thanks in Advance.
    Prakash

    Mr Prakash,
    Why are you asking this question multiple times in every forum you can spell?
    Valid responses have been presented to you already two times.
    Can you explain why you can't follow them up, but continue to abuse this forum by repeating doc questions?
    Sybrand Bakker
    Senior Oracle DBA

  • How to send key for unicode characters?

    Hi Gurus,
    I want to send an unicode character to screen, but can't figure out a way to do so. In java, we can send a virtual key code using java.awt.event.KeyEvent. But how can I send a unicode character to the screen? Must I implement an input method? how to do that....?
    Anyone can give me some ideas?
    Thanks,
    Perky

    Found tha answer myself: set System.useCodePage to false

  • How to write a file into UNIX!

    Hi Group!
    I am trying to write an error file into UNIX directory using 'OPEN DATASET ERRFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT'. But unfortunately i am getting a dump as it is giving the subrc 8 and dumping with CX_SY_FILE_OPEN_MODE.
    The path looks like /sap/DE1/batch/data/SCM_YM/partfiles/HGMEH011.20071001150344
    Is there any special command or way to write the file into UNIX?
    Quick response would be of great help.
    Suresh

    The detailed error is
    The file '&FILENAME&' was not opened, or was opened in the wrong mode.
    Can you please try to create a new file that does not exist.
    then we can check whether you have authorization or not.
    OPEN DATASET to a file already opened - in the same internal mode - triggers the exception.
    THtas why you just create a file with some rough name ( may be ur name) intially and then check.
    bye sasi

  • How to write excel file (.xlsx) using file adapter without using java code

    Hi All,
    In soa suite 11g Is there any ways to write the data to the excel ( xlsx ) file using fileadapter and not using java code..Thanks in Advance

    Hi Siva,
    I don't think there is any way to write .xls file directly. You'll have to use some Java API (iText etc.) to create an .xls file. However, you can write .csv file that can be easily converted into .xls at the target end. In MS, it opens as Excel file if delimiter is comma *,*.
    Regards,
    Neeraj Sehgal

  • How to write to file using fixed width columns

    I need to write some data to a text file such that it is formatted in columns of fixed width. Each column can have different width. eg if i have to write 5 fields in each record the first field would be of 5 characters, second field of 3 characters and so on.
    Can u please suggest how I can do it. Its urgent.

    Can't you search? Now you know what to google on: java 5 printf
    Kaj

  • How to write UDL file in Labview for Database connection

    Hi
    I am using SQL Server database. I am making connection with SQL by using UDL file. If I create  Normal UDL file in windows and make connection it happens.  I want to change or add some parameter Like database name. If I am changing this value by using labview, the file gets corrupted, and not able to make connection with SQL.
    I want to create database by program. User should not create the database. 
    Kindly suggest me the proper solution. 
    Regards
    Prabhakant Patil
    [email protected] 
    Regards
    Prabhakant Patil

    It may look like a text file, but it's not a text file that uses plain-old ASCII. If you open it in Notepad you won't see anything obvious. You actually have to open the UDL file with a hex editor, and you will see the differences. Specifically:
    The file starts with the header FF FE. This indicates Unicode. LabVIEW does not support Unicode.
    Each characters is actually 2 bytes. Thus, the first character you see in Notepad is "[" (for the section start). In hex this is 05 for plain-old ASCII, but 05 00 for Unicode (which is what's actually in the file).
    Thus, if you absolutely must write out the file using LabVIEW you will need to write it out in binary mode, inserting the 0x00 bytes, and the FF FE at the start. 
    Message Edited by smercurio_fc on 03-24-2010 09:39 AM

  • How to Write a file from hex format to another format

    hi I am trying to create a file (IBM AFP-printer format) from the hex file which i have created after reading that IBM afp file. Now i have to do some changes in that hex file data and store it back to the same format.
    I have tryed storing it using:
    Writer out = new OutputStreamWriter(outputStream,"Cp1252");
    but it is taking hex format only.
    I have checked encoding of afp file by this code
    File inputFile = new File( "C:\\ACode\\new2.afp" ) ;
              FileInputStream inputStream = new FileInputStream(inputFile );
         InputStreamReader in = new InputStreamReader(inputStream);
    System.out.println(in.getEncoding());
    it is showing Cp1252 only.
    But i am unable to store it back to same format
    Thanks

    I don't really know what the IBM APF stream format is, but I suspect that your approach is not right. If you really want to read and write raw hex bytes, then do not use readers and writers; instead use pure streams. The reason is that readers and writers are designed to deal with character-oriented data, and will automatically perform translations on input and output.
    On the other hand, if you could find the correct encoding/decoding software for the IBM format in question, well then readers/writers would be fine, and you could do all of your "internal" work in unicode.

Maybe you are looking for