Results 1 to 5 of 5
  1. #1
    Snake006 is offline Senior Member
    Join Date
    Jun 2013
    Posts
    127
    Rep Power
    0

    Default FileReader problems

    Ok I know a lot of people have this kind of problem and I have tried various solutions but I just don't seem to be getting anyway. What I am trying to do is use a file containing data for GPA,tuition,courses,etc but I can't find the file. The file is in the C drive under documents(I have tried an absolute path as well) . The name of the file is stData. I need this as input. Here is 2 lines of my code



    Java Code:
    BufferedReader infile=new BufferedReader(new FileReader("C:\\stData.txt"));
                PrintWriter outfile=new PrintWriter(new FileWriter("C:\\sDataOut.out"));
    java.io.FileNotFoundException: C:\stData.txt (The system cannot find the file specified)

    Thank you

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: FileReader problems

    If it's under documents, why aren't you using a path to the documents folder? This code is looking for a file at the top-level C drive.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Snake006 is offline Senior Member
    Join Date
    Jun 2013
    Posts
    127
    Rep Power
    0

    Default Re: FileReader problems

    I have tried using the absolute path. When I try using the folder path I end up using illegal escape characters

  4. #4
    Snake006 is offline Senior Member
    Join Date
    Jun 2013
    Posts
    127
    Rep Power
    0

    Default Re: FileReader problems

    In order to make it easier I made a copy of the file and put it in the library in my netbean project I'm working on. I try retrieving it by doing this:
    BufferedReader infile=new BufferedReader(new FileReader("/txtStuff/stData.txt"));
    But it still can't find it

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: FileReader problems

    I'm not sure why you keep expecting this stuff to work. You have to point your code directly to where the file is. If the file is in the lib folder, the code needs to know to look in the lib folder.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Help with FileReader
    By MrSulfat in forum New To Java
    Replies: 6
    Last Post: 01-24-2013, 05:11 PM
  2. Using UNBUFFERED FileReader.
    By Spooge in forum New To Java
    Replies: 1
    Last Post: 10-11-2010, 09:03 AM
  3. FileReader problems
    By Maikl in forum New To Java
    Replies: 3
    Last Post: 12-14-2009, 12:51 PM
  4. FileReader help
    By emp in forum New To Java
    Replies: 1
    Last Post: 07-28-2009, 05:41 AM
  5. add FileReader to GUI
    By VinTiger in forum New To Java
    Replies: 8
    Last Post: 05-11-2009, 01:23 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
  •