• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

StringToken to integer conversion

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
ssdjgru1
Asked:
ssdjgru1
1 Solution
 
NevynCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now