|
-
January 12th, 2009, 02:45 PM
#1
Converting String to float
Hi everyone.
I need help again lol, im trying to code a load function, ive got it to read the files and put the values into strings, but i need to convert these to float type and nothing i try seems to work!
Code:
//Loads players saved statistics
void loadFile()
{
try {
FileReader file = new FileReader("winstat.dat");
BufferedReader buff = new BufferedReader(file);
String line = buff.readLine();
trans1 = line;
buff.close();
}
catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
try {
FileReader file = new FileReader("loosestat.dat");
BufferedReader buff = new BufferedReader(file);
String line = buff.readLine();
trans2 = line;
buff.close();
}
catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
try {
FileReader file = new FileReader("drawstat.dat");
BufferedReader buff = new BufferedReader(file);
String line = buff.readLine();
trans3 = line;
buff.close();
}
catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
message.setText(trans1);
}
The files contain single float numbers, e.g.: 6.0
Thanks for any help!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|