• Post Reply Bookmark Topic Watch Topic
  • New Topic

Appending contents in each line using Random AccessFile  RSS feed

 
Senthil Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
There is a file which has 'N' number of lines.
Now, i need to insert a String after each line in the same file.
can anyone help me in providing me a solution without creating an intermediate File

Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RandomAccessFile can be used to overwrite characters in a file, but it can't insert characters. You'll need to read the content of the file into memory, and then write the changed content back to disk in full.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!