Re: Is it correct about File.createNewFile()?
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Mon, 10 Oct 2005 14:08:13 -0600
Red Orchid <windfollowcloud@xxxxxxxxx> wrote:
> File f = new File("re:test.txt"); // #1
>
> try {
> boolean b = f.createNewFile();
> System.out.println(b);
> }
> The "re:test.txt" in #1 is wrong pathname.
> The 'f' will not be created.
>
> But, the code above outputs "true".
>
> Is it correct?
It appears that a file is created by the name "re", and created. The
interpretation of the filename parameter to the File constructor is left
unspecificed, so you can't call the behavior wrong. So long as re-using
that File instance to recreate the same file again fails (which it does)
and opening a stream of that file reads back no data (which it does),
the spec is being fulfilled.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
.
- Prev by Date: Re: Is it correct about File.createNewFile()?
- Next by Date: Re: new forum -- homework help/chit chat/easy communication
- Previous by thread: Re: Is it correct about File.createNewFile()?
- Next by thread: Re: Is it correct about File.createNewFile()?
- Index(es):
Relevant Pages
|