Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clear the text then add new text to file

 
Aya Muhannad
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello;
I have a code that clear old text then add new text to text file afterthat download the file
but the problem my code dose not add new text


plz help me to clear old text then add new text to text file
 
K. Tsang
Bartender
Posts: 3444
13
Android Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to "clear old text then add new text to text file" then isn't that the same as overwriting the file with the new text? If so why need to clear old text?
 
Tony Docherty
Bartender
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your FileWriter should probably be writing to the file denoted by 'filename' and not by 'name' and as K. Tsang has said there is no need to clear old text, just remove the 'true' parameter from the FileWriter constructor to overwrite the file with the new data.
 
Aya Muhannad
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put the filename parameter to FileWriter but the new text is not written in a file
and I want to replace the old text with new text
 
Tony Docherty
Bartender
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code you are now running
 
Aya Muhannad
Greenhorn
Posts: 22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved that prblem by this code
 
Tony Docherty
Bartender
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to hear you have it working and thanks for updating the thread with the solution
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic