Archived

This topic is now archived and is closed to further replies.

sushi-one

[java] Parsing methods??

Recommended Posts

Well, assuming you have already read in the line to be parsed, then two ways that come to mind to get the value after the '=' are


a = "value=21"
then
String [] b = a.split( "=", 2); // b[1] is everything after the '='

or
String b = a.substring( a.indexOf( '=') +1); // b is everything after the '='



[edited by - simb on January 24, 2004 2:54:53 AM]

Share this post


Link to post
Share on other sites
Yep,
Integer.parseInt( "12345")
returns the integer 12345, and there are similar ones for Double, Float, Short, Long, Byte, Boolean and maybe some more (just look in the JavaDocs for those classes for the exact method names)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Take a look at java.util.Properties - you can use it to load a button/value-type file as a Hashtable with great ease.

--cfmdobbie

Share this post


Link to post
Share on other sites