aspose file tools*
The moose likes Beginning Java and the fly likes how to append in a file from beginning. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to append in a file from beginning." Watch "how to append in a file from beginning." New topic
Author

how to append in a file from beginning.

saurabh agr
Ranch Hand

Joined: Apr 14, 2010
Posts: 37
hello all,
i am doing some file related work at some point i want to append the file from the beginning but i don't know how to do this, please help.

i m using File Writer constructor with second argument true for appending in the file but it appends from the end of the file but i want to insert something at beginning of the file contents.
Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

You can't, or at least not directly. File systems usually don't allow prepending, only appending. You'll need to use a temporary file as an intermediate solution. Write to the temporary file first, then delete the original file and rename the temporary file to the original file.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: how to append in a file from beginning.