Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Delete line from a text file

 
mohammed moin
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at our FAQ: Edit An Existing File
 
mandlar suurla
Ranch Hand
Posts: 67
Debian Linux PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!