Problem finding file with File Input

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Empyrean
    New Member
    • Mar 2007
    • 3

    #1

    Problem finding file with File Input

    I'm attempting to make my first program that involves file input, but I'm running into problems finding the .txt file.

    I placed the file inside the same folder as the rest of the project, but it still doesn't seem to be finding it. Am I doing something wrong?


    Code:
     
    try
            {
                in = new Scanner(new File("File Reading.txt"));
                String test = in.nextLine();
                System.out.println(test);
            }
            catch(Exception i)
            {
                System.out.println("Error: " + i.getMessage());
            }




    That's the portion of the code that is supposed to read the file. I cut out the declaration of the Scanner in and the rest of the class, but I figured that wouldn't have anything to do with the problem I'm having.
  • Empyrean
    New Member
    • Mar 2007
    • 3

    #2
    Oh never mind, I figured it out myself.


    I still needed to specify the file location in the code.


    Feel free to delete this now. :)

    Comment

    Working...