[5176] in java-interest

home help back first fref pref prev next nref lref last post

Re: Problems on append a exist file.

daemon@ATHENA.MIT.EDU (Nigel Back)
Wed Jan 31 14:33:17 1996

From: Nigel Back <nrb@garland.bt.co.uk>
Date: Wed, 31 Jan 96 08:53:08 GMT
To: mark@hactl.com.hk, msenocak@arachnid.microweb.com
Cc: java-interest@java.sun.com


> From daemon@java.sun.com Tue Jan 30 18:04:50 1996
> Date: Mon, 29 Jan 1996 23:26:58 -0800
> From: Mete Senocak <msenocak@arachnid.microweb.com>
> X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
> Mime-Version: 1.0
> To: mark@hactl.com.hk
> Cc: java-interest@java.sun.com
> Subject: Re: Problems on append a exist file.
> Content-Type> : > text/plain> ; > charset=us-ascii> 
> Content-Transfer-Encoding: 7bit
> Sender: owner-java-interest@java.sun.com
> X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
> Content-Length: 802
> 
> Hi Mark:
> 
> mark@hactl.com.hk wrote:
> > 
> >      Hi, everybody,
> > 
> >      I am now writing a Java application (not applet) for file management.
> >      The problem I meet is I can not append new line to the exist file.
> >      Each time I create a FileOutputStream, it overwrite the exist file.
> >      Could someone please tell me how to append a file? Thanks a lot!
> > 
> >      regards,
> > 
> >      Mark
> > -
> 
> Without looking at your code, let me ask this: Did you place your file 
> pointer at the end of the file before writing to the file? If not, that 
> explains the cause of your problem.
> 
> This will put the pointer at the end of your file:
> 
> yourFile.seek(yourFile.length());
> 
> Good luck,
> 
> - Mete
> -
> This message was sent to the java-interest mailing list
> Info: send 'help' to java-interest-request@java.sun.com
> 
You will need to use the RandomAccessFile class and not FileOutputStream to have the necessary control over the pointer. Seek will work fine then.

Nigel B.
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post