parse a text file

I have a text file of the form:
33.581 14.994 92.452
33.461 14.976 90.967
32.861 13.656 90.629
33.463 12.623 90.924
34.845 15.053 90.276

These are x, y and z coordinates.  I need to read them into a java program and store them in arrays as floats.  What is the best way to do this?
vonsterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
BufferedReader in = new BufferedReader(new FileReader("a.txt"));
String line = null;
while (null!=(line=in.readLine()))
{
    String[] tokens = line.split(" ");
    float[] f = new float[tokens.length()];
    for (int i=0; i<f.length; i++)
    {
       f[i] = Float.parseFloat(tokens[i]);
    }

    // do what you need to with float array

}
in.close();

0
RuadRauFlessaCommented:
Hey objects you devil you beat me to it again. :)

Have a nice day pal.
0
SaMuElCommented:
import java.io.*;
class Reader{
      static float[] x=new float[100],y=new float[100],z=new float[100];
      
      static void read() throws IOException{
            BufferedReader in = new BufferedReader(new FileReader("text.txt"));
            String s;
            try{
                  for (int i=0;(s=in.readLine())!=null;i++){
                        x[i] = Float.parseFloat(s.split(" ")[0]);
                        y[i] = Float.parseFloat(s.split(" ")[1]);
                        z[i] = Float.parseFloat(s.split(" ")[2]);
                  }
            }
            catch (Exception e){}
            in.close();
      }

      public static void main(String[] args) throws IOException{
      read();
      for (int i=0; i<x.length;i++){
            System.out.println(x[i] + " " + y[i] + " " + z[i]);
      }
      }
}
This code has some obvious limitations.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

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.