• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file i/o question

 
daniel schulken
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am i correct in thanking that the only way to append to a file is using RandomAccessFile?
 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel,
The answer is NO.
Read this from JAVA API
FileWriter :
public FileWriter(String´┐ŻfileName,
boolean´┐Żappend) throws IOException

Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written. Parameters:fileName - String The system-dependent filename.append - boolean if true, then data will be written to the end of the file rather than the beginning.Throws:IOException - if the specified file is not found or if some other I/O error occurs.
You can use as below.
BufferedWriter bw=new BufferedWriter(new FileWriter("Test.txt",true));
This will append you data to the file "Test.txt".
Solaiappan
 
daniel schulken
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic