Results 1 to 2 of 2
  1. #1
    doha786 is offline Member
    Join Date
    Mar 2009
    Posts
    48
    Rep Power
    0

    Arrow FileNotFoundException problem

    i built one program to save/create JTable as (.file) extension by using ObjectOutputStream... but once i need to read by using JFileChooser it prints FileNotFoundException:
    java.io.FileNotFoundException: file.file (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method
    if i use direct file-path then working nicely..

    Java Code:
    JFrame frame=new JFrame();
    JTable table;
    
            JFileChooser fc = new JFileChooser("C:/Java/CLASS");
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY ); 
            
            int returnVal = fc.showOpenDialog(null);
    
     if (returnVal == JFileChooser.APPROVE_OPTION) {
          File file=fc.getSelectedFile();
          String filename= file.getName();
    
        //String filename=("C:/Java/CLASS/file.file");
                                                    
              try {
              FileInputStream fis=new FileInputStream(filename);
              ObjectInputStream ois=new ObjectInputStream(fis);
              table = (JTable) ois.readObject();
                                    
                    
              JScrollPane jsc=new JScrollPane(table);
                    
              frame.add(jsc);
              frame.setSize(500,700);
              frame.setVisible(true);
    how can i solve this ?
    what we are thinking, it might not be true

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    If you already have a File object, why don't you open the InputStream using that? I.E. new FileInputStream(File) rather than new FileInputStream(String)

Similar Threads

  1. FileNotFoundException
    By ProgrammingPup in forum Advanced Java
    Replies: 4
    Last Post: 12-30-2009, 01:29 AM
  2. filenotfoundexception :@
    By wildheart in forum New To Java
    Replies: 2
    Last Post: 04-25-2009, 09:56 AM
  3. handle FileNotFoundException
    By minifish in forum New To Java
    Replies: 13
    Last Post: 11-08-2008, 02:01 AM
  4. java.io.FileNotFoundException
    By thevoice in forum New To Java
    Replies: 5
    Last Post: 06-13-2008, 08:38 AM
  5. FileNotFoundException
    By PeonLover in forum New To Java
    Replies: 1
    Last Post: 12-26-2007, 06:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •