|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcontrol.io.FileOutputStream
public class FileOutputStream
A file output stream is an output stream for writing data to a
File
or to a FileDescriptor
. Whether or not
a file is available or may be created depends upon the underlying
platform. Some platforms, in particular, allow a file to be opened
for writing by only one FileOutputStream (or other
file-writing object) at a time. In such situations the constructors in
this class will fail if the file involved is already open.
FileOutputStream
is meant for writing streams of raw bytes
such as image data. For writing streams of characters, consider using
FileWriter
.
File
,
FileDescriptor
,
FileInputStream
Constructor Summary | |
---|---|
FileOutputStream(File file)
Creates a file output stream to write to the file represented by the specified File object. |
|
FileOutputStream(File file,
boolean append)
Creates a file output stream to write to the file represented by the specified File object. |
|
FileOutputStream(String name)
Creates an output file stream to write to the file with the specified name. |
|
FileOutputStream(String name,
boolean append)
Creates an output file stream to write to the file with the specified name. |
Method Summary | |
---|---|
void |
close()
Closes this file output stream and releases any system resources associated with this stream. |
protected void |
finalize()
Free internal data structures used by this file object. |
void |
flush()
flush the current stream. |
void |
write(byte[] b)
Writes b.length bytes from the specified byte array
to this file output stream. |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this file output stream. |
void |
write(int b)
Writes the specified byte to this file output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, notifyAll, toString, wait |
Constructor Detail |
---|
public FileOutputStream(String name, boolean append) throws FileNotFoundException, IOException
true
, then bytes
will be written to the end of the file rather than the beginning.
A new FileDescriptor
object is created to represent this file connection.
name
- the system-dependent filenameappend
- true for appending data at end of file, false for overwrite file
FileNotFoundException
- if the file not exists or is not a regular file
IOException
- can not be created, or cannot be opened for any other reasonpublic FileOutputStream(String name) throws FileNotFoundException, IOException
FileDescriptor
object is
created to represent this file connection.
name
- the system-dependent filename
FileNotFoundException
- if the file not exists or is not a regular file
IOException
- can not be created, or cannot be opened for any other reasonpublic FileOutputStream(File file, boolean append) throws FileNotFoundException, IOException
File
object. If the second argument is
true
, then bytes will be written to the end of the file
rather than the beginning. A new FileDescriptor
object is
created to represent this file connection.
file
- the file to be opened for writing.append
- true for appending data at end of file, false for overwrite file
FileNotFoundException
- if the file not exists or is not a regular file
IOException
- can not be created, or cannot be opened for any other reasonpublic FileOutputStream(File file) throws FileNotFoundException, IOException
File
object. If the second argument is
true
, then bytes will be written to the end of the file
rather than the beginning. A new FileDescriptor
object is
created to represent this file connection.
file
- the file to be opened for writing.
FileNotFoundException
- if the file not exists or is not a regular file
IOException
- can not be created, or cannot be opened for any other reasonMethod Detail |
---|
public void write(int b) throws IOException
write
method of OutputStream
.
write
in interface BasicOutputStream
b
- the byte to be written.
IOException
- if an I/O error occurs.public void write(byte[] b) throws IOException
b.length
bytes from the specified byte array
to this file output stream.
write
in interface BasicOutputStream
b
- the data.
IOException
- if an I/O error occurs.OutputStream.write(byte[], int, int)
public void write(byte[] b, int off, int len) throws IOException
len
bytes from the specified byte array
starting at offset off
to this file output stream.
write
in interface BasicOutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.
IOException
- if an I/O error occurs.public void flush() throws IOException
NOTE: Not Supported
flush
in interface BasicOutputStream
IOException
public void close() throws IOException
If this stream has an associated channel then the channel is closed as well.
close
in interface BasicOutputStream
IOException
- if an I/O error occurs.protected void finalize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |