Below is a snippet of the text file format structure
Historical Sales for: 12th of October 2019, 11:37 am
PRODUCT NAME QUANTITY
Coke B 5
Historical Sales for: 21st of October 2019, 8:15 pm
PRODUCT NAME QUANTITY
Peanuts 2
I want to process only the column labels and row values, but not including the main heading; in this case, the Historical Sales for: 12th of October 2019, 11:37 am.
This is the code I wrote to process the text using the regex (\\b)
StringBuilder temporary = new StringBuilder();
InputStream inputStream = new FileInputStream(new File(FILE_NAME));
BufferedReader readFile = new BufferedReader(new InputStreamReader(inputStream));
String next;
while ((next = readFile.readLine()) != null) {
temporary.append(next).append("\n");
}
next = String.format("%13s", ""); // spacing for column headers
System.out.println(temporary.toString().replaceAll("(\\b)", next));