I am converting an object (ArrayList) in XML and then storing that XML as a file on local machine. When there are large number of data, the XML takes too long to write in a File or doesnt write at all (gives some exception).
xmlSource = xmlConverter.convert(object); // object here is no.of ArrayLists..
FileWriter fw = new FileWriter(f); fw.write(xmlConverter.getXML());
fw.write() takes too much time. Is there any other way which doesnt eat up so much memory ???
For 100K records or more the above code didnt work on my machine.. ( i had kept JVM Heap size to Max. 1300K.. ) The reason was the XMLConverter was not able to convert that much data into XML So i wrote the code to divide all the ArrayLists in chunks and then convert them and write them into the same file..
FileWriter fw = new FileWriter(new File("foo.xml , true);
the flag in the constructor is for Appending the new data to same file.. and so file can be generated without any trouble..