This discussion is archived
3 Replies Latest reply: Jan 12, 2009 10:31 PM by 807589 RSS

Converting String to float

807589 Newbie
Currently Being Moderated
ok - ive posted this issue on a few forums, to no avail
http://www.codeguru.com/forum/showthread.php?s=2285d18e7073ae78020b723c4091a679&t=468683
[nha khoa|http://www.sieuthi77.com/main/nhakhoa.html].com/showthread.php?t=1485

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!

//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!