This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Erase a line in a file and insert a new line onn that line. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Erase a line in a file and insert a new line onn that line." Watch "Erase a line in a file and insert a new line onn that line." New topic
Author

Erase a line in a file and insert a new line onn that line.

Minseong Kim
Greenhorn

Joined: Jun 28, 2010
Posts: 5
hi.

how can I search and erase a line in a file by using Java codes?

for example, if have README,

and I want to erase line 23 and insert new information, how am I able to do this using Java codes?

Thanks.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
See this FAQ: Edit An Existing File http://faq.javaranch.com/java/EditAnExistingFile

Also see this post that points to the Java classes that you will use: http://www.coderanch.com/t/279094/Streams/java/Delete-line-text-file#1283566
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Erase a line in a file and insert a new line onn that line.