So the idea is that I have this .json file that I need to read. It is so big that I can't even open it using notepad or Visual studio code.
I tried this:
BufferedReader in = new BufferedReader(new FileReader("path to the file"));
String line = in.readLine();
and I get this error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.base/java.util.Arrays.copyOf(Arrays.java:3536) at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:228) at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:735) at java.base/java.lang.StringBuilder.append(StringBuilder.java:227) at java.base/java.io.BufferedReader.readLine(BufferedReader.java:372) at java.base/java.io.BufferedReader.readLine(BufferedReader.java:392) at com.ReadJSON.TagValues.listFilesForFolder(TagValues.java:133) at com.ReadJSON.TagValues.listFilesForFolder(TagValues.java:129) at com.ReadJSON.TagValues.listFilesForFolder(TagValues.java:129) at com.ReadJSON.TagValues.listFilesForFolder(TagValues.java:129) at com.ReadJSON.Main.main(Main.java:18)
I searched on internet and some solutions were to change memory settings, but it doesn't work, it returns the same error. Another problem is that the entire file is ONELINE. The entire content of the file is written in a single line. I think I have to break the reading part of the line at a certain time so it doesn't get over the maximum allocated memory, store the value and start to read again from where I left. Doing this over and over until the end of the line.
Any suggestions of how should I read this file? Should I try a different way to read it or is there a trick to break the readLine()?
Thanks!