aspose file tools*
The moose likes Beginning Java and the fly likes string to number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "string to number" Watch "string to number" New topic
Author

string to number

ngoc thai
Greenhorn

Joined: Sep 08, 2001
Posts: 2
Dear JR members,
What is the best way to convert a string of digits to either an integer, float or double? Please advice.
Here are the two sample strings: "28769", "78.14159"
Thanks
NT
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
For the float, use the static method Float.parseFloat(String s)
for the int, use the static method Integer.parseInt(String s)
etc.
etc.
Each primitive wrapper class has a method like this.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Ngoc,
To format the float or double values you can use:
java.text.DecimalFormat.
Regards,
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: string to number