Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deletion of space between two lines

 
nandireddy sreekanthreddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a text file in that how can i delete the space between two lines using io package . what i mean is, i have three lines gap between the lines . i want to remove that space between that lines
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
you can read the file line by line and write everithing but the empty lines to a second file. or you can read all to a Vector (all but the empty lines) and when done, you write the contents of the vector back to the same file.
you can read the file by creating a BufferedReader Object.
you can write the file by creating a PrintWriter Object.
(or other from the io familly, depends in the input/output you want and need)
pascal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic