This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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
 
 
subject: Erase a line in a file and insert a new line onn that line.