Re: creating/copying files..




"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


.



Relevant Pages

  • Re: creating/copying files..
    ... Mark Thomas wrote: ... 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. ... I now have a file object in memory which will eventually 'represent' a file on the hard disc. ...
    (comp.lang.java.help)
  • Re: Dynamically Creating instances of classes which subclass a com
    ... definitions which are not the same as the constructor, ... "Brett Kelly" wrote: ... > an object array representing the constructor parameters, ... > Mark - thanks for the reply! ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [uml-devel] [PATCH 5/6] slab: Annotate slab
    ... On Wed, Sep 3, 2008 at 6:42 PM, Steve VanDeBogart ... We can't mark all of them as initialized ... initialize all the bytes of an object). ... run the constructor on the memory region. ...
    (Linux-Kernel)
  • Re: Collection interface..
    ... Frances wrote: ... I'm catching EmailException in catch block, but if email doesn't get sent I don't get an exception... ... For example, if the To address is invalid in some way, we can successfully send the email, but it won't be delivered - it will bounce. ... again thank you very much Mark.. ...
    (comp.lang.java.help)
  • Re: Question concerning object-oriented programming
    ... If at the end of the constructor the ... inspectof the state fails to verify key assertions, ... should mark themselves Unusable and thereafter all procedures should ...
    (comp.programming)