java.io
Class FileOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FileOutputStream
-
- All Implemented Interfaces:
- Closeable, Flushable, AutoCloseable
public class FileOutputStream extends OutputStream
A file output stream is an output stream for writing data to aFile
or to aFileDescriptor
. 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 usingFileWriter
.- Since:
- JDK1.0
- See Also:
File
,FileDescriptor
,FileInputStream
,Files.newOutputStream(java.nio.file.Path, java.nio.file.OpenOption...)
-
-
Constructor Summary
Constructors Constructor and Description FileOutputStream(File file)
Creates a file output stream to write to the file represented by the specifiedFile
object.FileOutputStream(File file, boolean append)
Creates a file output stream to write to the file represented by the specifiedFile
object.FileOutputStream(FileDescriptor fdObj)
Creates a file output stream to write to the specified file descriptor, which represents an existing connection to an actual file in the file system.FileOutputStream(String name)
Creates a file output stream to write to the file with the specified name.FileOutputStream(String name, boolean append)
Creates a file output stream to write to the file with the specified name.
-
Method Summary
Methods Modifier and Type Method and Description void
close()
Closes this file output stream and releases any system resources associated with this stream.protected void
finalize()
Cleans up the connection to the file, and ensures that theclose
method of this file output stream is called when there are no more references to this stream.FileChannel
getChannel()
Returns the uniqueFileChannel
object associated with this file output stream.FileDescriptor
getFD()
Returns the file descriptor associated with this stream.void
write(byte[] b)
Writesb.length
bytes from the specified byte array to this file output stream.void
write(byte[] b, int off, int len)
Writeslen
bytes from the specified byte array starting at offsetoff
to this file output stream.void
write(int b)
Writes the specified byte to this file output stream.-
Methods inherited from class java.io.OutputStream
flush
-
-
'Dev. 자바 > API 및 이론' 카테고리의 다른 글
[JAVA API] java.io.FileWriter (0) | 2012.08.08 |
---|---|
[JAVA API] java.io.FileReader (0) | 2012.08.08 |
[JAVA API] java.io.FileInputStream (0) | 2012.08.08 |
[JAVA API] java.io.File (1) | 2012.08.08 |
[JAVA API] java.lang.Enum<E>, 열거형 (0) | 2012.08.08 |