Results 1 to 3 of 3
  1. #1
    tomh420 is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Question Exception in thread "main" java.io.FileNotFoundException

    Hey, I have started writing this program and I don't have any syntax errors but when I go to run the program I get this:

    Exception in thread "main" java.io.FileNotFoundException: fileinput.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileReader.<init>(Unknown Source)
    at Textinput.main(Textinput.java:13)

    here's my code

    Java Code:
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.util.Scanner;
    
    import javax.swing.JOptionPane;
    
    public class Textinput {
    		
    	public static void main(String[] args) throws FileNotFoundException 
    						
    	{
    							
    		Scanner inFile = new Scanner(new FileReader("fileinput.txt"));
    		
    		String firstinteger;
    		String secondinteger;
    		String thirdinteger;
    		
    		firstinteger = inFile.next();
    		secondinteger = inFile.next();
    		thirdinteger = inFile.next();	
    		
    		inFile.close();
    		
    		
    		JOptionPane.showMessageDialog(null, "The first integer is " + firstinteger + "\n" + "The second integer is " + secondinteger + "\n" + "The third integer is " + thirdinteger, "Values", 
    		JOptionPane.INFORMATION_MESSAGE);	
    			
    		
    		}
    	
    	
    	
    }
    I have tried making sure that my extensions are not repeated also I have tried saving the text file in different places and changing the directory path.

    I'm quiet new to java every time i change something something else goes wrong :(

    cheers

  2. #2
    tomh420 is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Default Re: Exception in thread "main" java.io.FileNotFoundException

    Fixed, i hadn't checked about my extensions

    sorry

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Exception in thread "main" java.io.FileNotFoundException

    Moved from Eclipse.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 11-02-2012, 11:38 PM
  2. Replies: 2
    Last Post: 06-20-2012, 12:18 AM
  3. Replies: 5
    Last Post: 12-21-2011, 06:44 PM
  4. Replies: 4
    Last Post: 11-05-2010, 11:50 PM
  5. Replies: 5
    Last Post: 06-22-2010, 03:51 PM

Posting Permissions

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