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.
-
Method Summary
Modifier and TypeMethodDescriptioncreateOutputStream
(File file) Creates a file output stream to write to the file represented by the specified File object.createOutputStream
(File file, boolean append) Creates a file output stream to write to the file represented by the specified File object.createOutputStream
(String name) Creates an output file stream to write to the file with the specified name.createOutputStream
(String name, boolean append) Creates an output file stream to write to the file with the specified name.
-
Method Details
-
createOutputStream
Creates a file output stream to write to the file represented by the specified File object. A new FileDescriptor object is created to represent this file connection. First, if there is a security manager, its checkWrite method is called with the path represented by the file argument as its argument.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.
- Parameters:
file
- the file to be opened for writing.- 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 reasonSecurityException
- if a security manager exists and its checkWrite method denies write access to the file.- See Also:
-
createOutputStream
Creates a file output stream to write to the file represented by the specified File object. A new FileDescriptor object is created to represent this file connection. First, if there is a security manager, its checkWrite method is called with the path represented by the file argument as its argument.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.
- Parameters:
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 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 reasonSecurityException
- if a security manager exists and its checkWrite method denies write access to the file.- See Also:
-
createOutputStream
Creates an output file stream to write to the file with the specified name. A new FileDescriptor object is created to represent this file connection. First, if there is a security manager, its checkWrite method is called with name as its argument.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.
- Parameters:
name
- the system-dependent filename- 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 reasonSecurityException
- if a security manager exists and its checkWrite method denies write access to the file.- See Also:
-
createOutputStream
Creates an output file stream to write to the file with the specified name. A new FileDescriptor object is created to represent this file connection. First, if there is a security manager, its checkWrite method is called with name as its argument.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.
- Parameters:
name
- the system-dependent filenameappend
- if true, 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 reasonSecurityException
- if a security manager exists and its checkWrite method denies write access to the file.- See Also:
-