Home » Developer & Programmer » JDeveloper, Java & XML » Read Unicode chars and insert into Oracle DB
Read Unicode chars and insert into Oracle DB [message #177424] Wed, 14 June 2006 09:15
Mahesh P
Messages: 69
Registered: September 2004
Member
Guys,

I am having a file in which some of the text was in Unicode format.
I want to read this file (see attachement) in Java and insert into oracle database.
The following is the code for reading the unicode string from the file.

public String loadString(String filename) {
    StringBuffer text = new StringBuffer();
    FileInputStream instream;
    BufferedInputStream buffer;
    int readint;
    try {
      instream = new FileInputStream(filename);
      buffer = new BufferedInputStream(instream);
      Reader reader = new InputStreamReader(buffer, "Unicode");
       while ((readint = reader.read()) != -1) {
        text.append( (char) readint);
      }
      buffer.close();
      instream.close();
    } catch (Exception e) {e.printStackTrace(); }
   return text.toString();
  }

Java is reading the correct unicode (i can see this while debuggin the code). Is there any way to insert the Unicode chars to DB.

I am viewing the chars in the html page with Encoding set to 'Central European - Windows).but it doesn't show the correct one..

Please help me how to insert to Oracle DB.
My Oracle DB is UTF-8 charset.
  • Attachment: UnicodeEx.csv
    (Size: 0.14KB, Downloaded 1474 times)

[Updated on: Tue, 08 March 2011 03:48] by Moderator

Report message to a moderator

Previous Topic: XML Parsing - Out of memory error and Process slow down
Next Topic: JDBC 10g XA Drivers and Rank( )
Goto Forum:
  


Current Time: Thu Apr 18 07:04:31 CDT 2024