Loading a Text File

I am new to Java3D I am trying to read in a text File that contains x,y and z coordinates. I want to put them into a point Array. How do I get the points from the file so they are displayed on the scene. This is what I tried.

StringTokenizer st = new StringTokenizer(line);
            time = Double.valueOf(st.nextToken()).doubleValue();
            x = Double.valueOf(st.nextToken()).doubleValue();
            y = Double.valueOf(st.nextToken()).doubleValue();
            z = Double.valueOf(st.nextToken()).doubleValue();

              PointArray par = new PointArray(vertexCount, vertexFormat);
              Point3d[] pts1 = new Point3d[1];
              pts1[0] = new Point3d(x,y,z);

               Color3f[] co= {new Color3f(1.0f,0.0f,0.0f), new Color3f(1.0f,0.3f,0.5f),new Color3f(0.8f,0.3f,0.9f)};
              par.setCoordinates(0,pts1);
              par.setColors(0,co);

            //System.out.println(time+ ",  "+x);
                 this.addGeometry(par);

but it didn’t work. I would appreciate any assistance available.

This doesn’t look bad to me, assuming you are incrementing the indices of pts[] rather than sending each new point3d to pts1[0].

What error message is it raising? As a start you could get the values output to the command line with a simple System.out.println(“x= “+x+”, y=”+y+", z="+z) type command. That would at least tell you whether the tokens are being parsed correctly.

??

The code snippet just creates a single vertex? What do you expect to see then?