开发者

How to read a big clob data from a file?

开发者 https://www.devze.com 2023-03-13 05:11 出处:网络
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.

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

精彩评论

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