	   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 data
	{
	public double x[];
	public data(double[] xi)
	{
	int n=xi.length;
	x=new double[n];
	for(int i=0;i<n;i++) {x[i]=xi[i];}
	}	
	public String toString() {return ""+x[0]+" "+x[1];}
	}        
public class readfromfile12
{	
     public static double[][] inputdouble(String filename) 
     {
	 //reading double values from one line of data    
	 Scanner fin=new Scanner(filename);
     double a[][]=inputdouble(fin);
     return a;
     }
     
    public static double[][] inputdouble(Scanner fin) 
    {
	 ArrayList<data> a=new ArrayList<data>();
	 int mmax=0;
	 double b[][];
	 int n=0,m=0;
	 String s1="";
	 ArrayList<String> s2=new ArrayList<String>();
       while (fin.hasNextLine())
       { s1=fin.nextLine();
         StringTokenizer token=new StringTokenizer(s1);
         m=token.countTokens();
         if(m>mmax) mmax=m;
         double aa[]=new double[m];
         int j=0;           
         while(token.hasMoreTokens())
         { Double ax=new Double(token.nextToken());
           aa[j++]=ax.doubleValue();
         }
         data vx=new data(aa);
         a.add(vx);
       n++;
	   }
     b=new double[n][mmax];
     int k=0;
     Iterator i=a.iterator();
     while(i.hasNext()) {data vx=(data)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);
}
}
