D
Danger_Duck
Almost a silly question, but I want to make sure I have it right:
Java.io.File:
Say I want to know if C:\folder\file.txt exists.
Do I just do this:
File file = new File(C:\folder\file.txt);
if (file.exists()) {
//confirm existence
System.out.print("it's there dude \n");
}
Does the above work for confirming whether or not the file is there?
If so, I guess the File class doesn't ACTUALLY create new files?
Because without reading any documentation I would think the first line
actually made a file there and therefore (of course!) it will
exist...NOT
I ask because the javadoc isn't too clear-does the file instance
actually mean a new file?
Thanks to whoever can enlighten me on what this is actually doing.
File
public File(String pathname)
Creates a new File instance by converting the given pathname
string into an abstract pathname. If the given string is the empty
string, then the result is the empty abstract pathname.
Parameters:
pathname - A pathname string
Throws:
NullPointerException - If the pathname argument is null
Java.io.File:
Say I want to know if C:\folder\file.txt exists.
Do I just do this:
File file = new File(C:\folder\file.txt);
if (file.exists()) {
//confirm existence
System.out.print("it's there dude \n");
}
Does the above work for confirming whether or not the file is there?
If so, I guess the File class doesn't ACTUALLY create new files?
Because without reading any documentation I would think the first line
actually made a file there and therefore (of course!) it will
exist...NOT
I ask because the javadoc isn't too clear-does the file instance
actually mean a new file?
Thanks to whoever can enlighten me on what this is actually doing.
File
public File(String pathname)
Creates a new File instance by converting the given pathname
string into an abstract pathname. If the given string is the empty
string, then the result is the empty abstract pathname.
Parameters:
pathname - A pathname string
Throws:
NullPointerException - If the pathname argument is null