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 usingString 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.
精彩评论