Hi Java Experts,
I need your advice on the shortest and simplest way to parse the following type of string data from text files, where they will be persisted into database:
Rodney James 20 Olympic Cr 2 children $50,000 IBM
Kelly Julie Furgusion 3 Brooks St 3 children $80,000 Lehman Brothers Pty Ltd
There are numerous ways to approach this including the following methods:
( i ) Scanner class,
( ii ) String class,
( iii ) A combination of String.split(), Pattern and Matcher.
( iv ) StringTokenizer class,
( v ) StringBuffer
There are many lines on the header and footer of page that should be ignored by testing the number of columns in each row prior to parsing.
The first approach that comes into mine is option ( iii ) and checking the content of each substring using regular expression and looping. This method is quite lengthy and I am wondering whether there is simpler way to achieve it by evaluating the whole string, possibly using regular expressing which I am still grasping.
Your advice would be greatly appreciated.
Thanks,
Jack