	   import java.io.*;
	   import java.util.*;
	   import javax.swing.*;
       import javax.swing.table.*;
       import java.awt.*;

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 readfromfile4
{	
     public static double[][] inputdouble(String filename) throws IOException
     {
	 //reading double values from one line of data    
	 BufferedReader fin=new BufferedReader(new FileReader(filename));
     double a[][]=inputdouble(fin);
     return a;
     }
     
    public static double[][] inputdouble(BufferedReader fin) throws IOException
    {
	 ArrayList<data> a=new ArrayList<data>();
	 int mmax=0;
	 double b[][];
	 int n=0,m=0;
	 String s1="";	 
	 try{
       while(fin!=null)
       { s1=fin.readLine();
       if(s1==null)break;
         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++;
	   }
       } catch(EOFException e_eof)
          {
          //close ffile
          try{fin.close();
      } 
      catch(NullPointerException e) {}   
      catch(IOException e)
             {
             System.err.println("Error Closing File\n"+e.toString());
             System.exit(1);
             }
          } //End of EOFException
     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[i].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);
  BufferedReader fin=new BufferedReader(new FileReader(f));
  double number[][]=inputdouble(fin);
  JOptionPane.showMessageDialog(null,toString(number),"sequential file reading",JOptionPane.PLAIN_MESSAGE);
  System.exit(0);
}
}
