开发者

How to read a big clob data from a file?

I need to read a file line by line.

The data in the file can be anything, a small string or a huge Clob/Blob/XML.

But I am facing a problem, I am using String row = dataInputStream.readLine() t开发者_StackOverflow中文版o get the data, line by line. But if it is a big Clob/Blob/XML data, this method is throwing error, because it is not able to fit the huge data into the String. What should I do?


You should not be using a reader. If this is a binary (unknown) file, you should read it as bytes from something like a BufferedInputStream. Then do whatever processing you need with the data. Apache commons-io has a nice IOUtils class to easily read bytes from a stream into a byte array, see http://commons.apache.org/io/api-2.0/org/apache/commons/io/IOUtils.html.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜