Im going to start by posting what the data from the text file looks like, this is just 4 lines of it, the actually file is a couple hundred lines long.
Friday, September 9 2011 5:00AM - 11:59PM STH 1102 HOLD DO NOT BOOK
Report Printed on 9/08/2011 at 2:37 PM Page 1 of 1
Friday, September 9 2011 5:00AM - 11:00PM STH 4155 (BOARDROOM) HOLD - DO NOT BOOK
Hold - Do Not Book Report Printed on 9/08/2011 at 2:37 PM Page 1 of 1
Friday, September 9 2011 5:00AM - 11:59PM UC 2 (COMPUTER LAB) HOLD DO NOT BOOK
do not book Report Printed on 9/08/2011 at 2:37 PM Page 1 of 1
Friday, September 9 2011 5:00PM - 11:00PM AH GYM USC ORIENTATION 2011 - REVISED
USC Orientation 2011 Report Printed on 9/08/2011 at 2:37 PM Page 1 of 1
Each little section of text is on one line in the text file, separated by many spaces which dont show up in the question format for some reason, I will use the first section of text as an example of what data I am trying to get.
Here is the data Id like to get from the file Friday
, 5:00
, 11:59
, STH 1102
, HOLD DO NOT BOOK
, and then ignore the read of the line, all the info on the 2nd line of the section of text is too be ignored, but in the text file itself it is all on one line. and then with this data, I would like to save each piece into a variable. Or instead the part of the data that says HOLD DO NOT BOOK
is sometimes formatted like this: DO NOT BOOK
, HOLD - DO NOT BOOK
, if the regex finds any of theses it can ignore all the data in that line before and after.
Also if you I could I would like to take the times that have PM in them and add 12 to them so they are in 24 hour format.
Here is how I am currently reading the lines entirely. And then I just call this function once the user has put the path in the scheduleTxt JTextfield. It can read and print each line out fine.
public void readFile () throws IOException
{
try
{
FileInputStream fstream = new FileInputStream(scheduleTxt.getText());
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null)
{
System.out.println (str1);
}
in.close();
}
catch (Exception e){
System.err.println("Error: " + e.getMessage());
}
}
I know theres in this question, hopefully you understand what Im asking, if something is unclear just ask, Thanks! Beef.
Update: I just thought maybe it would help to explain my intentions for this data, first off I will be converting any PM times into 24 hour format, and then according to the 4th piece of data(STH 1102
) I call a insert function that will use the ODBC driver in order to insert the other data from the line into a database