• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Delete line from a text file

 
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.
 
Bartender
Posts: 9620
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at our FAQ: Edit An Existing File
 
Ranch Hand
Posts: 67
PHP Debian Linux
  • 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
 
Oh the stink of it! Smell my tiny ad!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic