I have a requirement where a huge HTML file must be read and displayed in the front-end of my application. The HTML file size is around 25MB. Tried several options like:
Option 1:
try (Scanner scnr = new Scanner(file);) {
while (scnr.hasNextLine()) {
String line= scnr.nextLine();
}
}
Option 2:
FileUtils.readFileToString(file, "UTF-8");
Option 3:
IOUtils.toString(new FileInputStream(new File(file)), "UTF-8")
All the above 3 options are failing to read the file. I see no error. The processing just stops and the webpage throws an "error" popup with no info.
Problem seems to be that the entire HTML file content is read as a single line of string.
Is there a way in which I can read this file?
I went through several other questions here to see if there is a possible solution, but nothing seems to be working for this case.