Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Scanner - file not found?

  1. #1
    Junior Member
    Join Date
    Apr 2024
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Scanner - file not found?

    Please explain what happens when File looks properly initiated but Scanner can't adopt this File?

    Create object file, it is opened, I can apply methods, read path, properties, length etc.
    File file = new File("in.txt");

    Next trying to create new Scanner and it throws exception file not found? How?
    Scanner scan = new Scanner(file);

    Utils and io library imported.

  2. #2
    Member Helium c2's Avatar
    Join Date
    Nov 2023
    Location
    Kekaha, Kaua'i
    Posts
    117
    Thanks
    1
    Thanked 3 Times in 3 Posts

    Default Re: Scanner - file not found?

    Just write in the exception. File not found exception. try { catch } statement inside. Then compile it.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Scanner - file not found?

    I can apply methods, read path, properties, length etc.
    File file = new File("in.txt");

    Next trying to create new Scanner and it throws exception file not found? How?
    Can you post a small, complete program that compiles and shows the problem when executed?

    Which of the methods that you called makes you think the file exists?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: August 19th, 2014, 12:12 PM
  2. Priority Queue Heap Incorrect Output & No File found Scanner
    By OverZealous in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 14th, 2013, 07:23 PM
  3. File not found
    By radulescuiulia in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 29th, 2013, 06:00 PM
  4. [SOLVED] jar file not found
    By user2013 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 13th, 2013, 02:12 PM
  5. Replies: 3
    Last Post: December 2nd, 2011, 11:53 AM

Tags for this Thread