What I am doing is to read one file line by line, format every line, then write to a new file. But the problem is that the file is huge, nearly 178 MB. But always getting error message: IO console updater error, java heap space. Here is my code:
public class fileFormat { public static void main(String[] args) throws IOException{ String strLine; FileInputStream fstream = new FileInputStream("train_final.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(fstream)); BufferedWriter writer = new BufferedWriter(new FileWriter("newOUTPUT.txt")); while((strLine = reader.readLine()) != null){ List<String> numberBox = new ArrayList<String>(); StringTokenizer st = new StringTokenizer(strLine); while(st.hasMoreTokens()){ numberBox.add(st.nextToken()); } for (int i=1; i< numberBox.size(); i++){ String head = numberBox.get(0); String tail = numberBox.get(i); String line = head + " "+tail ; System.out.println(line); writer.write(line); writer.newLine(); } numberBox.clear(); } reader.close(); writer.close(); } } How can I avoid this error message? Moreover, I have set the VM preference: -xms1024m
BufferedWriter