Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

inputstream  RSS feed

 
Jackie Wang
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to change a program from
lnr = new LineNumberReader(new FileReader(strFileName), BUFFER_SIZE);
while ((sLine = lnr.readLine()) != null) {
. blah blah .....

to
InputStreamReader because of try to handle the UTF8.
Any one can help with the syntax?
Thansk and appreciated that.
Bryan
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, to be clear, are you trying to figure out how to read a text file encoded in UTF-8 a line at a time?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If so, then are you perhaps trying to discover wrapping an InputStreamReader in a BufferedReader?
 
Jackie Wang
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have posted this in JDBC forum but no reply yet:
Maybe here is more suitable:
I try to open a file with 1 chinese character in UTF format and i read it tried to store into the oracle database.
FileInputStream fis = new FileInputStream(strFileName); // i have define the strfilename
BufferedReader breader = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
I got this error:
com.sssw.rt.util.AgoSystemDatabaseException: ORA-01401: inserted value too large
for column
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at com.sssw.rt.util.AgoException.<init>(Compiled Code)
at com.sssw.rt.util.AgoException.<init>(Compiled Code)
at com.sssw.rt.util.AgoApiException.<init>(Compiled Code)
at com.sssw.rt.util.AgoSystemException.<init>(Compiled Code)
at com.sssw.rt.util.AgoUnrecoverableSystemException.<init>(Compiled Code
)
at com.sssw.rt.util.AgoSystemDatabaseException.<init>(Compiled Code)
at com.sssw.srv.ambry.AmbryModifyStatement.prepareAndExecuteUpdate(Compi
led Code)
anyone can help where goes wrong?
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sounds more like a database issue than an I/O problem, but what exactly are you sticking in the database? You create a reader, but what are you doing to read the character you want to insert into the database?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jackie,
I don't know whether this will help you, and I assume you haven't already seen it, but here is a "tip" from the DevX Web site that may be relevant:
http://archive.devx.com/free/tips/tipview.asp?content_id=4045
The "tip" is entitled "Insert Multi-Lingual Characters in JDBC" and is by "Gajendran G".
Alternatively, have you looked through the code samples available from Oracle's TechNet Web site:
http://technet.oracle.com/sample_code/tech/java/sqlj_jdbc/content.html
Or the Ask Tom Web site:
http://asktom.oracle.com
Hope this helps.
Good Luck,
Avi.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd agree with Jason. This seems like a database problem. Can your column accomodate the unicode characters that you're inserting ?

[1] Inserting a unicode char into a nchar(1) should be fine.
[2] Inserting two unicode chars into a nchar(1) will cause the ORA-01401 error code. Some databases will silently truncate the data (e.g. PostgresQL)
[3] The other case is:

if you try to insert NCHAR data into a regular CHAR column and the character data in NCHAR (Unicode) form cannot be converted to the database character set, the character will be replaced by a replacement character defined by the database character set.

Pho
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!