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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -