The warning it gave you tells you what you should do:
Note: Recompile with -Xlint:deprecation for details.
Basically, you are being told you are using a method that is no longer supported - there is a new, better one you should be using.
C:\slop>javac -Xlint FileTest.java
FileTest.java:30: warning: [deprecation] toURL() in java.io.File has been deprecated
System.out.println("toURL() = " + f.toURL());
Checking the API for the toURL method shows this:
This method does not automatically escape characters that are illegal in URLs. It is recommended that new code convert an abstract pathname into a URL by first converting it into a URI, via the toURI method, and then converting the URI into a URL via the URI.toURL method.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joined: Oct 19, 2012
it is frustrating I am just using text pad to write the code. Apologize..
Secondly, looks like the method exists() on class "File" does not look for files (such as .doc, .xls etc) it checks only sub directory.
boolean exists = f.exists();
System.out.println("exists() = " + exists);
This prints exists only if there are sub directories under it.
How do I modify to check for any "files" inside the directory ?
Mei Fdo wrote:it is frustrating I am just using text pad to write the code. Apologize..
No need to apologize - there is a lot to learn when you are just starting. the code tags are a feature of this site, not what you use to write your code with. Check out this article. There are probably some other articles you should read found here as well to get an idea how this site works best.