473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

java parsing

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 .


Regards
Raj
Apr 6 '09 #1
4 1725
dmjpro
2,476 2GB
@sgxbytes

What you tried so far?
If you tried then show us the code.
Read each line which contains "PERFORMANCE MEASUREMENT :: ".
Then cut the string from "PERFORMANCE MEASUREMENT :: ".
Then you tokenize the string by space deliminator.
I think now you can have your target full filled ;)
Apr 6 '09 #2
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]);

}
}
}


i have done upto this to get the string out like

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>

if i use space delimiter ,i will not get the expected one

i need the above string into 3 like

1) BEFORE
2) OOE RESERVE GROUP MEMBER Info
3) Fri Apr 03 10:16:47 ICT 2009
Apr 6 '09 #3
dmjpro
2,476 2GB
@sgxbytes

See now you cut the last character ... just you can do it during "substring" just last parameter will be "length-1".
Then tokenize on the basis of space deliminator. Then take the first token as your desired first token then keep adding untill ">>>>" token encounters to get the second one then rest is last desired token ;)
Apr 6 '09 #4
r035198x
13,262 8TB
Have a look at
Expand|Select|Wrap|Line Numbers
  1. String regex = "(BEFORE|AFTER).*?>>>>.+?>DEBUG";
  2. Pattern p = Pattern.compile(regex, Pattern.MULTILINE);
  3. Matcher m = p.matcher(s);
  4. while (m.find()) {
  5.     String line = m.group();
  6.         String[] pieces = line.split(">");
  7.     System.out.println(Arrays.toString(pieces));
  8. }
  9.  
After you have those pieces in an array you can then play with them at your leisure.
Apr 6 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
13
by: Ajay | last post by:
hi! can you call a Python application from a Java program? does this require any additional package to be installed? thanks cheers
13
by: cjl | last post by:
Hey all: I'm working on a 'pure' python port of some existing software. Implementations of what I'm trying to accomplish are available (open source) in C++ and in Java. Which would be...
3
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
0
by: precious | last post by:
i'm trying to split my xml configuration file to files implementing the parsing using xerces in java (DOMparser). my project uses a "fromXML" parsing design and here's what i tried in the node...
4
by: Dr. Laurence Leff | last post by:
I am writing a Java program to read in XML file, modify some elements slightly, and then write it out. That XML file is prepared in Docbook. It works fine, except that it is disturbing the...
4
by: Marcin Cenkier | last post by:
Hi, I can create a schema from xsd file: Schema s = SchemaFactory.newInstance(_XMLConstants.W3C_XML_SCHEMA_NS_URI_).newSchema(new StreamSource(res.getInputStream())); but when using...
458
by: wellstone9912 | last post by:
Java programmers seem to always be whining about how confusing and overly complex C++ appears to them. I would like to introduce an explanation for this. Is it possible that Java programmers...
1
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
5
by: PatlaDJ | last post by:
Java SAX parser, please need a clue how to get the raw XML code of the currently parsing event... needed for logging, debugging purposes. Here's and example, letting me clarify exactly what i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.