Forums Register Login

Delete line from a text file

+Pie Number of slices to send: Send
Hello friends,

I have a problem in deleting a particular line from a text file.

Say,

this is my text file,

java is good

java is superb

java is fantastic

My question is how to delete the second line from the file?

I am using BufferedReader,BufferedWriter, file reader, filewriter for file operations.

Any suggestions will be greatly appreciated.

Thanks.
+Pie Number of slices to send: Send
Have a look at our FAQ: Edit An Existing File
+Pie Number of slices to send: Send
I would use first readlines in some array and then when wanting to delete line then i add skip in code(simple if statement). My idea
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 5136 times.
Similar Threads
File reading and manipulation
Removing a line of text from a csv file
Stream for reading and deleting line
Deleting a row in Jtable as well as from the .txt database
check that main() method exists in java program
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:04:31.