Solved

StringToken to integer conversion

Posted on 2000-05-13
1
183 Views
Last Modified: 2010-04-01
Is there any possibility to convert the value that comes from stringTokenizer to an integer value ?
I'am reading a simple string of integer values and then I want to tokenise it and put the values into integer variables.
0
Comment
Question by:ssdjgru1
1 Comment
 
LVL 2

Accepted Solution

by:
Nevyn earned 200 total points
ID: 2806779
Use class Integer.

StringTokenizer tok = ...;
int value = Integer.parseInt(tok.nextToken());
The parseInt method takes a String argument, and may throw a NumberFormatException is the string contains invalid characters for a number. There are similar methods available for the Double, Float, etc in the java.lang package. Check out the codumentation for details.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now