Package org.plumelib.util
Class FileWriterWithName
java.lang.Object
java.io.Writer
java.io.OutputStreamWriter
java.io.FileWriter
org.plumelib.util.FileWriterWithName
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Just like
FileWriter
, but adds a getFileName()
method and overrides
#toString()
to give the file name.-
Field Summary
-
Constructor Summary
ConstructorDescriptionFileWriterWithName
(File file) Constructs a FileWriterWithName object given a File object.FileWriterWithName
(File file, boolean append) Constructs a FileWriterWithName object given a File object.FileWriterWithName
(String fileName) Constructs a FileWriterWithName object given a file name.FileWriterWithName
(String fileName, boolean append) Constructs a FileWriterWithName object given a file name with a boolean indicating whether or not to append the data written. -
Method Summary
Modifier and TypeMethodDescriptionReturns the name of the file being written by this.toString()
Returns the name of the file being written by this.Methods inherited from class java.io.OutputStreamWriter
append, append, close, flush, getEncoding, write, write, write
Methods inherited from class java.io.Writer
append, nullWriter, write, write
-
Constructor Details
-
FileWriterWithName
Constructs a FileWriterWithName object given a file name.- Parameters:
fileName
- the system-dependent filename- Throws:
IOException
- if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
-
FileWriterWithName
Constructs a FileWriterWithName object given a file name with a boolean indicating whether or not to append the data written.- Parameters:
fileName
- the system-dependent filenameappend
- boolean iftrue
, then data will be written to the end of the file rather than the beginning.- Throws:
IOException
- if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
-
FileWriterWithName
Constructs a FileWriterWithName object given a File object.- Parameters:
file
- a File object to write to- Throws:
IOException
- if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
-
FileWriterWithName
Constructs a FileWriterWithName object given a File object. If the second argument istrue
, then bytes will be written to the end of the file rather than the beginning.- Parameters:
file
- a File object to write toappend
- iftrue
, then bytes will be written to the end of the file rather than the beginning- Throws:
IOException
- if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason- Since:
- 1.4
-
-
Method Details