Results 1 to 5 of 5
  1. #1
    Naani is offline Member
    Join Date
    Aug 2011
    Posts
    3
    Rep Power
    0

    Default java.io.FileNotFoundException

    Hi All,

    I'm getting the below error when I tried to read a simple abc.txt file by using the attached javacode.
    My Classpath is set as %CLASSPATH%;.; and the abc.txt,javacode are placed in the same folder.I'm getting an error during runtime.

    Can any one please help me how to overcome this problem.

    java.io.FileNotFoundException-javacode.jpg
    Exception in thread "main" java.io.FileNotFoundException: abc.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.jav a:120)
    at java.io.FileInputStream.<init>(FileInputStream.jav a:79)
    at copystream.main(copystream.java:10)
    Java Result: 1

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default

    Try:
    Java Code:
    File inFile = new File("abc.txt");
    System.out.println(inFile.getAbsolutePath());
    at the top of your method to find out where it's using as its base directory.
    Since you're in an IDE it's likely to be the top of the project, not the src directory (which is what the one I'm using at the moment does).

  3. #3
    Naani is offline Member
    Join Date
    Aug 2011
    Posts
    3
    Rep Power
    0

    Default

    Hi Tolls,

    I tried the thing which you mentioned above but still it's throwing the same error.
    Please help me out.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default

    That wasn't supposed to fix it.
    It was supposed to tell you where it was looking for the file...

  5. #5
    Naani is offline Member
    Join Date
    Aug 2011
    Posts
    3
    Rep Power
    0

    Default

    Hi All,
    The extension of my file is abc.txt.txt and it was not abc.txt and this is the reason it getting errord out.
    It's working fine now..

    Thanks Tolls...

Similar Threads

  1. java.io.FileNotFoundException: \temp\env.out
    By JJones in forum New To Java
    Replies: 3
    Last Post: 05-19-2011, 11:07 PM
  2. Java.util.zip FileNotFoundException
    By deredowl in forum Advanced Java
    Replies: 4
    Last Post: 05-18-2011, 09:37 AM
  3. Replies: 1
    Last Post: 04-14-2011, 05:04 AM
  4. Replies: 1
    Last Post: 04-01-2009, 07:34 PM
  5. java.io.FileNotFoundException
    By thevoice in forum New To Java
    Replies: 5
    Last Post: 06-13-2008, 08:38 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
  •