Re: New File with a Directory
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Sun, 30 Dec 2007 16:55:27 -0500
Mark Thornton wrote:
Alan wrote:I was wondering why Java behaves this way. . . . Below are a few
lines of code with nearly duplicate methods called for a file and then
a directory. One method (methodWithoutNew) just assigns a File
variable to the input File object (no "new" operator). The other
method (methodWithNew) uses the "new" operator to create its file
object with the same name as the input File object.
{ System.out.println( file.getName() + " does not exist!!!" ); }
The reason would be more obvious if you replaced file.getName() with file in all of the print statements (in this context file is equivalent to file.toString()).
Alan: is just the name enough, without the whole path, enough to find the file to see if it exists?
--
Lew
.
- Follow-Ups:
- Re: New File with a Directory
- From: Mark Thornton
- Re: New File with a Directory
- References:
- New File with a Directory
- From: Alan
- Re: New File with a Directory
- From: Mark Thornton
- New File with a Directory
- Prev by Date: Re: Use of AssertionError
- Next by Date: Re: New File with a Directory
- Previous by thread: Re: New File with a Directory
- Next by thread: Re: New File with a Directory
- Index(es):
Relevant Pages
|