satellite03
IS-IT--Management
hi ,
i think a sigle character is the smallest string.
but when i wrote to convert this charater to integer it gave me error.
i wrote
although parseInt() demands a string , but a single character is also can be treated as a string. right?
then why it could not convert the character into integer??
my file
--------
400 25.81
600 33.82
800 40.94
1000 51.62
compilation erroe
-----------------
javac ReadFileExample.java
ReadFileExample.java:13: cannot resolve symbol
symbol : method parseInt (char)
location: class java.lang.Integer
int n = Integer.parseInt(oneByte);
^
1 error
>Exit code: 1
whats wrong with this???
is there any atoi() function (as in C ) in java which can convert char to int????
i have no problem to extract the integer but i was intentionally trying to convert the char into integer by using methods. why i failed???
i think a sigle character is the smallest string.
but when i wrote to convert this charater to integer it gave me error.
i wrote
Code:
import java.io.*;
class ReadFileExample
{
public static void main( String args[]) throws IOException
{
char oneByte;
File f = new File ("d:\\data.txt");
FileInputStream fis = new FileInputStream (f) ;
oneByte = (char) fis.read();
int n = Integer.parseInt(oneByte);
System.out.println("integer =" + n );
fis.close();
}
}
although parseInt() demands a string , but a single character is also can be treated as a string. right?
then why it could not convert the character into integer??
my file
--------
400 25.81
600 33.82
800 40.94
1000 51.62
compilation erroe
-----------------
javac ReadFileExample.java
ReadFileExample.java:13: cannot resolve symbol
symbol : method parseInt (char)
location: class java.lang.Integer
int n = Integer.parseInt(oneByte);
^
1 error
>Exit code: 1
whats wrong with this???
is there any atoi() function (as in C ) in java which can convert char to int????
i have no problem to extract the integer but i was intentionally trying to convert the char into integer by using methods. why i failed???