I have a Java program that does queries on a table for records meeting specific criteria and put the data in a file. I store the data that will go to the file in a byte array. Problem is I may have a large set of results that I may need to allocate a large enough byte array that maybe too big for the computer's memory.
I know there is FileOutputStream out = new FileOutputStream(String filename, boolean append) and write to the file over and over getting some results from the database at a time. But I was told the pointer to a place in the file in the FileOutputStream is unreliable.
It is very IMPORTANT that the data coming from the database is on the right positions in the file because the file will go to a mainframe.
What very reliable methods do you all suggest I do to write to a file several times when I am fetching large amounts of data from a database? Thanks.