Class used to write to files residing in filesystem.
main
FileWriter fw = null
try
fw = new FileWriter "existingFile.dat" append true
catch IOException e
print "Could not open file for writing."
return
// contentsToWrite holds byte data which needs to be written.
Byte[] contentsToWrite
print "Initial file size: " & fw.get size
fw.write contentsToWrite
print "Size after write: " & fw.get size
fw.close
Opens a file for writing. The file will be truncated unless appendToEnd parameter is true.
main
FileWriter fw = null
try
fw = new FileWriter "existingFile.dat" append true
catch IOException e
print "File could not be opened."
return
print "File open successful."
fw.close
Sets the current position. The newPosition should be non-negative and not more than the current size of the file.
main
FileWriter fw = new FileWriter "file.dat"
try
fw.set position to 1000
catch IOException e
print "File position could not be set."
return
print "Position set successfully."
Gets the current file position.
main
FileWriter fw = new FileWriter "file.dat"
print "Current file position: " & fw.get position
fw.close
Gets the size of the file.
main
FileWriter fw = new FileWriter "file.dat"
print "File size: " & fw.get size
fw.close