Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Stream/String Manipulation

Status
Not open for further replies.

jcale4

Programmer
Aug 31, 2004
63
US
I have a data stream that I am feeding into a method as a string, connects to a DB2 database and inserts the values contained in the string. Here is what the string looks like:

Code:
==SS39939294==
03012|39|33|32|2|232|9995
0333|34|007|32|2|7|95345
0392|39|33|32|2|232|9995
04492|39|3|32|8|77|95175
0392|39|33|6|2|232|554

I need to "trim" out the stamp (==SS39939294==), which represents the Unix time of the stream. I believe i will need to use the replaceAll method of the String class with a regular expression, but i'm not quite sure how to do that. Can anyone help?
 
Some hints:

1.- Post just once
2.- You should post this in the Java forum
3.- If you just want to take the String between "==" I don't think you need regexp

Code:
String yourString = yourData;
String timeStamp = yourData.substring(yourData.indexOf("==")+2,yourData.lastIndexOf("=="));

would do the trick.

Cheers,

Dian
 
please do not post standard Java questions in the J2EE forum.
forum269 is for J2SE / general Java questions.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top