	   import java.io.*;
	   import java.util.*;
	   import javax.swing.*;
       import javax.swing.table.*;
       import java.awt.*;
       import  java.io.File;
       import java.io.FileNotFoundException;
       import java.util.Scanner;

class data1
	{
	public double x[];
	public data1(ArrayList<String> xi)
	{	
	int n=xi.size();
	x=new double[n];
	Iterator i=xi.iterator();
	int ix=0;
    while(i.hasNext()) 
    {String vx=(String)i.next();
    Double ax=new Double(vx);
    x[ix]=ax.doubleValue();
    ix++;
    }	
	}
}	
        
public class readfromfile13
{	
     public static double[][] inputdouble(String filename) 
     {
	 //reading double values from one line of data1    
	 Scanner fin=new Scanner(filename);
     double a[][]=inputdouble(fin);
     return a;
     }
     
    public static double[][] inputdouble(Scanner fin) 
    {
	 ArrayList<data1> a=new ArrayList<data1>();
	 int mmax=0;
	 double b[][];
	 int n=0,m=0;
	 String s1="";
	 ArrayList<String> s2=new ArrayList<String>();
       while (fin.hasNextLine())
       { s1=fin.nextLine();
         ArrayList<String> s3=new ArrayList<String>();
         Scanner f3=new Scanner(s1); 
         while (f3.hasNext())
         {s3.add(f3.next());}
         m=s3.size();
         if(m>mmax) mmax=m;
         data1 vx=new data1(s3);
         a.add(vx);
       n++;
	   }
     b=new double[n][mmax];
     int k=0;
     Iterator i=a.iterator();
     while(i.hasNext()) {data1 vx=(data1)i.next();b[k++]=vx.x;}
     return b;
     }     
          
     public static String toString(double a[][])
     {
	 String s="";
     for(int i=0;i<a.length;i++)
     {
	 for(int j=0;j<a[0].length;j++)    
     {s+="a["+i+"]["+j+"] = "+a[i][j]+" ";}
     s+="\n";
     }
     return s;
	 }
               
     	
public static void main(String args[]) throws IOException
{	
  String s1="a.txt";
  JFileChooser fc=new JFileChooser();
  ExampleFileFilter filter = new ExampleFileFilter();
  filter.addExtension("txt");
  filter.setDescription("text file : .txt");
  fc.setFileFilter(filter);
  if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {File file = fc.getSelectedFile();s1=file.getName(); }
  File f=new File(s1);
  Scanner fin=new Scanner(f);
  double number[][]=inputdouble(fin);
  JOptionPane.showMessageDialog(null,toString(number),"sequential file reading",JOptionPane.PLAIN_MESSAGE);
  System.exit(0);
}
}
