i am having problems in reading the contents of my .dat file.
the contents of my .dat file are the following:
10.20 60.20 70.20 25.25
1.1 2.2 3.3 4.4
my expected output should look like this:
--------- --------- --------- ---------
10.20 60.20 70.20 25.25
1.10 2.20 3.30 4.40
but when i run it, it displays like this O_O:
--------- --------- --------- ---------
10.20 60.20 70.20 25.25
10.20 60.20 70.20 25.25 1.10 2.20 3.30 4.40
how come the second set of numbers were out of the line...
im confused... i need help
import java.util.*;
import java.io.*;
class roll
{
public static void main(String[]args)throws Exception
{
Scanner ah=new Scanner(new FileReader("text.dat"));
Formatter fmt = new Formatter();
double w,x,y,z;
System.out.println("-------- -------- -------- --------");
while(ah.hasNext())
{
w=ah.nextDouble();
x=ah.nextDouble();
y=ah.nextDouble();
z=ah.nextDouble();
fmt.format("%8.2f %8.2f %8.2f %8.2f",w,x,y,z);
System.out.println(fmt);
}
}
}