• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modifying file data

 
ramakrishna ranga
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Text file contains following data

artist1
title1
1
artist2
title2
2
artist3
title3
0
artist4
title4
-1

I want to modify it as

artist1
title1
1
artist2
title2
2
artist3
title3
0

by deleting the strings of
artist4
title4
-1

This is my code


My problem is its deleting whole data from file. please any one tell me how can i delete particular data in a file.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ramakrishna ranga:
...My problem is its deleting whole data from file. please any one tell me how can i delete particular data in a file.

I'm not sure I'm following your logic, but I don't see any decision-making code for what to keep and what to delete. Something like...

[ September 26, 2007: Message edited by: marc weber ]
 
bart zagers
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see the deletion is in the replaceAll.

The problem is that you call flush on the FileWriter fr and then close it.
You should call the flush on the BufferedWriter br.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic