DthingApi
Public Member Functions | Protected Member Functions | List of all members
java.io.FileOutputStream Class Reference
Inheritance diagram for java.io.FileOutputStream:
java.io.OutputStream

Public Member Functions

 FileOutputStream (File file) throws FileNotFoundException
 
 FileOutputStream (File file, boolean append) throws FileNotFoundException
 
 FileOutputStream (FileDescriptor fd)
 
 FileOutputStream (String path) throws FileNotFoundException
 
 FileOutputStream (String path, boolean append) throws FileNotFoundException
 
void close () throws IOException
 
void flush () throws IOException
 
final FileDescriptor getFD () throws IOException
 
void write (byte[] buffer, int byteOffset, int byteCount) throws IOException
 
void write (byte[] buffer) throws IOException
 
void write (int oneByte) throws IOException
 
- Public Member Functions inherited from java.io.OutputStream
 OutputStream ()
 
void close () throws IOException
 
void flush () throws IOException
 
void write (byte[] buffer) throws IOException
 
void write (byte[] buffer, int offset, int count) throws IOException
 
abstract void write (int oneByte) throws IOException
 

Protected Member Functions

void finalize () throws IOException
 

Detailed Description

An output stream that writes bytes to a file. If the output file exists, it can be replaced or appended to. If it does not exist, a new file will be created.

File file = ...
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(file));
...
} finally {
if (out != null) {
out.close();
}
}

This stream is not buffered. Most callers should wrap this stream with a BufferedOutputStream.

Use FileWriter to write characters, as opposed to bytes, to a file.

See also
BufferedOutputStream
FileInputStream

Constructor & Destructor Documentation

◆ FileOutputStream() [1/5]

java.io.FileOutputStream.FileOutputStream ( File  file) throws FileNotFoundException
inline

Constructs a new

that writes to

file

. The file will be truncated if it exists, and created if it doesn't exist.

Exceptions
FileNotFoundExceptionif file cannot be opened for writing.

◆ FileOutputStream() [2/5]

java.io.FileOutputStream.FileOutputStream ( File  file,
boolean  append 
) throws FileNotFoundException
inline

Constructs a new

that writes to

file

. If

append

is true and the file already exists, it will be appended to; otherwise it will be truncated. The file will be created if it does not exist.

Exceptions
FileNotFoundExceptionif the file cannot be opened for writing.

◆ FileOutputStream() [3/5]

java.io.FileOutputStream.FileOutputStream ( FileDescriptor  fd)
inline

Constructs a new

that writes to

fd

.

Exceptions
NullPointerExceptionif
fd
is null.

◆ FileOutputStream() [4/5]

java.io.FileOutputStream.FileOutputStream ( String  path) throws FileNotFoundException
inline

Constructs a new

that writes to

path

. The file will be truncated if it exists, and created if it doesn't exist.

Exceptions
FileNotFoundExceptionif file cannot be opened for writing.

◆ FileOutputStream() [5/5]

java.io.FileOutputStream.FileOutputStream ( String  path,
boolean  append 
) throws FileNotFoundException
inline

Constructs a new

that writes to

path

. If

append

is true and the file already exists, it will be appended to; otherwise it will be truncated. The file will be created if it does not exist.

Exceptions
FileNotFoundExceptionif the file cannot be opened for writing.

Member Function Documentation

◆ getFD()

final FileDescriptor java.io.FileOutputStream.getFD ( ) throws IOException
inline

Returns the underlying file descriptor.


The documentation for this class was generated from the following file: