How to append a new line to beginning of an existing file in java? -
assuming have txt file located in /mypath/sampletext.txt. how append new line beginning of file following in java while preserving original text file's contents?:
string startstr ="--start of file--";
looking way without having create intermediary 2nd file , make modifications existing file if possible.
read file contents first, prepend new line contents = newline + contents
, write new conent in same file (dont append).
Comments
Post a Comment