For processing a searchlog file I’m writing a Java class that should read and handle the file content line by line.
The Text in the Logfile looks like the following
[Integer User ID] [Queury] [Date: YYYY-MM-DD HH:MM:SS] [optional url]
I tried using a scanner and reading the lines with nextLine(), but this reads the whole file as one line. Any idea how I can ensure to only get one line at a time?
You can just grab the entire file as you have it, and then split the data:
As a side note:
System.getProperty("line.separator")is the universal new line character.An alternative method: