public interface TextFileOutputStreamFactory
On some platforms, text files need to be associated with a file encoding. TextFileOutputStream allows for the use of platform-specific utilities to associate the appropriate file encoding with newly created files.
By using the TextFileOutputStreamFactory to create text-based output streams, you can ensure that your file will be readable by users on all platforms.
Modifier and Type | Method and Description |
---|---|
java.io.FileOutputStream |
createOutputStream(java.io.File file)
Creates a file output stream to write to the file represented by the specified File object.
|
java.io.FileOutputStream |
createOutputStream(java.io.File file,
boolean append)
Creates a file output stream to write to the file represented by the specified File object.
|
java.io.FileOutputStream |
createOutputStream(java.lang.String name)
Creates an output file stream to write to the file with the specified name.
|
java.io.FileOutputStream |
createOutputStream(java.lang.String name,
boolean append)
Creates an output file stream to write to the file with the specified name.
|
java.io.FileOutputStream createOutputStream(java.io.File file) throws java.io.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 then a FileNotFoundException is thrown.
file
- the file to be opened for writing.java.io.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
reasonjava.lang.SecurityException
- if a security manager exists and its checkWrite method denies write access to the file.FileOutputStream.FileOutputStream(File)
java.io.FileOutputStream createOutputStream(java.io.File file, boolean append) throws java.io.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 then a FileNotFoundException is thrown.
file
- the file to be opened for writing.append
- if true, then bytes will be written to the end of the file rather than the beginningjava.io.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
reasonjava.lang.SecurityException
- if a security manager exists and its checkWrite method denies write access to the file.FileOutputStream.FileOutputStream(File, boolean)
java.io.FileOutputStream createOutputStream(java.lang.String name) throws java.io.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 then a FileNotFoundException is thrown.
name
- the system-dependent filenamejava.io.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
reasonjava.lang.SecurityException
- if a security manager exists and its checkWrite method denies write access to the file.FileOutputStream.FileOutputStream(String)
java.io.FileOutputStream createOutputStream(java.lang.String name, boolean append) throws java.io.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 then a FileNotFoundException is thrown.
name
- the system-dependent filenameappend
- if true, then bytes will be written to the end of the file rather than the beginningjava.io.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
reasonjava.lang.SecurityException
- if a security manager exists and its checkWrite method denies write access to the file.FileOutputStream.FileOutputStream(String, boolean)