473,795 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

java parsing

25 New Member
Hi,
I have text file which contains data in this way

DEBUG ooegroup.OoeGro upOnlineInterfa ceImpl - PERFORMANCE MEASUREMENT :: BEFORE OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:47 ICT 2009>
DEBUG ooegroup.OoeGro upOnlineInterfa ceImpl - reserveOOEGroup :>
DEBUG ooegroup.OoeGro upOnlineInterfa ceImpl - PERFORMANCE MEASUREMENT :: AFTER OOE RESERVE GROUP MEMBER Info >>>> Fri Apr 03 10:16:48 ICT 2009>
DEBUG reserve.Reserve OoeGroupRespons eMapper - Start : mapToOOEGroupRe sponse>


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 1738
dmjpro
2,476 Top Contributor
@sgxbytes

What you tried so far?
If you tried then show us the code.
Read each line which contains "PERFORMANC E MEASUREMENT :: ".
Then cut the string from "PERFORMANC E MEASUREMENT :: ".
Then you tokenize the string by space deliminator.
I think now you can have your target full filled ;)
Apr 6 '09 #2
sgxbytes
25 New Member
lineText = lnr.readLine();
while (lineText != null) {
lineText = lnr.readLine();
if (lineText != null) {
if (lineText.conta ins("PERFORMANC E MEASUREMENT")) {
s = lineText.toStri ng();
String delims = "PERFORMANC E MEASUREMENT ::";
String[] tokens = s.split(delims) ;
System.out.prin tln(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 Top Contributor
@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 MVP
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
5951
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 is this... is Perl so much better at parsing text files and outputing that we would see a substantial speed increase? We process about 10 million records in flat files a day for reformatting before putting them in a DB. Also, when it comes to...
13
3348
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
1828
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 easier for me to use as a reference? I'm not looking for automated tools, just trying to gather opinions on
3
8174
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 is this... is Perl so much better at parsing text files and outputing that we would see a substantial speed increase? We process about 10 million records in flat files a day for reformatting before putting them in a DB. Also, when it comes to...
0
5107
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 that i wanted outside - public void fromXML(Node element) { if (element.hasAttribute("fileName")){ String fileName= element.getAttribute("fileName"); element = getDOMParser().parse(fileName).getDocumentElement(); } ... continue as if it were the...
4
9884
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 carriage returns in places where they have meaning. Attached are a sample input file, the sample output file, and a simplified version of my Java program. My real file, examines certain element's attributes and adds certain elements to the DOM...
4
4576
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 XMLConstants.XML_DTD_NS_URI then an exception is thrown:
458
21491
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 simply aren't smart enough to understand C++? This is not merely a whimsical hypothesis. Given my experience with Java programmers --- the code they write and the conversations they have --- Occam's Razor points to this explanation. For example,...
1
4309
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 Linux there is an error. The code that fails is the following: SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); I´m sure that code is ok. In fact, I´ve found that in several...
5
7730
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 need: (see the comments in source) public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { //..Here... or maybe somewhere elsewhere I need on my disposal the raw XML code of every XML tags...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.