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: File checker not working

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default File checker not working

    Hey guys, writing something simple to see if a file exists and print a string if it does, not sure what is wrong with it though.

    import java.util.*;
     
    /**
     *
     * @author root
     */
    public class Myfilemaker {
        String firstFilepath;
     
        public static void main(String[] args) {
     
     
            Scanner user_input = new Scanner(System.in);
     
            String firstFilepath;
            System.out.println("File to search for: ");
            firstFilepath = user_input.next();
     
            System.out.println();
            System.out.println("Searching for " + firstFilepath + "\n");
            System.out.println(); 
     
     
            if (firstFilepath.exists()){                // <<< here is the error: "Cant find Symbol Method exists()"
                    System.out.println("File found");
            }
            else
            {
                  System.out.println("File not found");
                    }
     
    }
    }


  2. #2
    Member
    Join Date
    Sep 2013
    Posts
    64
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Default Re: File checker not working

    That's a String not a file.

    But I also know next to nothing about file I/O....and Java in general. So maybe I'm completely wrong lol

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: File checker not working

    You are 100% correct. OP is trying to work with the file name as a String instead of creating an instance of the File class.
    Improving the world one idiot at a time!

Similar Threads

  1. proxy checker keeps freezing
    By bean in forum What's Wrong With My Code?
    Replies: 13
    Last Post: June 3rd, 2013, 02:45 PM
  2. [SOLVED] Checker Program
    By maxreed in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 14th, 2012, 05:58 PM
  3. how to add Spell checker
    By hope2012 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 8th, 2012, 08:23 AM
  4. Spell checker using bags
    By kovynjd2010 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 16th, 2012, 12:09 PM
  5. Password Strength Checker
    By uthuth in forum Object Oriented Programming
    Replies: 1
    Last Post: February 6th, 2010, 04:09 PM

Tags for this Thread