Re: creating/copying files..
- From: "Rhino" <no.offline.contact.please@xxxxxxxxxx>
- Date: Wed, 28 Dec 2005 23:55:49 -0500
"Frances" <fdr58@xxxxxxxxx> wrote in message
news:43b34463$1_3@xxxxxxxxxxxxxxx
>
> Mark Thomas wrote:
>> Frances
>>
>> You need to realise that there is a difference between creating a File
>> object, which is what the constructor does, and creating an actual File
>> on your computer.
>> Very simply, if I write:
>>
>> File myFile = new File("sample.txt");
>>
>> I now have a file object in memory which will eventually 'represent' a
>> file on the hard disc. This is the file "instance" you mention. I can
>> now check to see if there already is a file of this name by using "if
>> (myFile.exists())...". I can create an actual file on the hard disc by
>> calling:
>>
>> myFile.createNewFile();
>>
>> Now the picture is complete. We have an instance of the File class in
>> memory which is acting as a proxy for the real file on disc. If You now
>> create, say a FileWriter passing this File object to the constructor, you
>> can now start writing to the real file.
>>
>> Hope that helps.
>>
>> Mark
>
>
> Mark, that helps A LOT, thank you.. this is precisely the kind of
> explanation I needed, it's very clear now.. create File Obj then
> pass this File Obj to constructor when creating the file...
>
> :) thanks again.... Frances
>
You may also benefit from the section on I/O in the Java Tutorial. Here's a
link to that chapter:
http://java.sun.com/docs/books/tutorial/essential/io/index.html.
Rhino
.
- References:
- creating/copying files..
- From: Frances
- Re: creating/copying files..
- From: Mark Thomas
- Re: creating/copying files..
- From: Frances
- creating/copying files..
- Prev by Date: Re: Suduko solver demo
- Next by Date: Re: Suduko solver demo
- Previous by thread: Re: creating/copying files..
- Next by thread: GUI program locking up...
- Index(es):
Relevant Pages
|