aspose file tools
The moose likes Java in General and the fly likes Java +Parsing a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Java +Parsing a text file " Watch "Java +Parsing a text file " New topic
Author

Java +Parsing a text file

Raj Jaya
Greenhorn

Joined: Oct 30, 2008
Posts: 1
Hi,
I have text file which contains data in this way

DEBUG ooegroup.OoeGroupOnlineInterfaceImpl - PERFORMANCE MEASUREMENT :: BEFORE OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:47 ICT 2009>
DEBUG ooegroup.OoeGroupOnlineInterfaceImpl - reserveOOEGroup :>
DEBUG ooegroup.OoeGroupOnlineInterfaceImpl - PERFORMANCE MEASUREMENT :: AFTER OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:48 ICT 2009>
DEBUG reserve.ReserveOoeGroupResponseMapper - Start : mapToOOEGroupResponse>


each line starts with DEBUG

i need to read this text and take the strings which contains PERFORMANCE MEASUREMENT and split this

PERFORMANCE MEASUREMENT :: BEFORE OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:47 ICT 2009>

into 1) BEFORE
2) OOE RESERVE GROUP MEMBER Info and 3) Fri Apr 03 10:16:47 ICT 2009

i mean to say into 3 tokens .

i have done upto this part

lineText = lnr.readLine();
while (lineText != null) {
lineText = lnr.readLine();
if (lineText != null) {
if (lineText.contains("PERFORMANCE MEASUREMENT")) {
s = lineText.toString();
String delims = "PERFORMANCE MEASUREMENT ::";
String[] tokens = s.split(delims);
System.out.println(tokens[1]);

}
}
}

splitted into

BEFORE OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:47 ICT 2009>
AFTER OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:48 ICT 2009>

how can i further split into
1) BEFORE
2) OOE RESERVE GROUP MEMBER Info and 3) Fri Apr 03 10:16:47 ICT 2009




Thanks in advance

Regards
Raj
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8566

rajj wrote:


Please check your private messages for an importand administrative matter


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32833
    
    4
One possible suggestion:

Use the String#split methods with a regular expression which recognises :: and >>>>?
Is BEFORE always one word? If so, you can repeat the procedure splitting the second String; you may be able to set a limit of 1 so it only splits on whitespace once.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Java +Parsing a text file
 
Similar Threads
executing jar file
Problem in parsing
Booking bus tickets with each member only max of 4 seats
programatic diff tool
Problem with continuation of tomcat service on WEB SERVER