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
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 35
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: 19216

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
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://jrebel.com/download
 
subject: how to append in a file from beginning.
 
Similar Threads
Line Feed Carriage Return problem
How to append the data into exsisting file ?
i will be grateful to u
Storing data into excisting Data
Storing data into excisting file