public class SyncableFileOutputStream extends FileOutputStream implements Syncable
FileOutputStream
Constructor and Description |
---|
SyncableFileOutputStream(File file)
Creates an instance of SyncableFileOutputStream using the
given File instance.
|
SyncableFileOutputStream(File file,
boolean append)
Creates an instance of SyncableFileOutputStream
that writes to the file represented by the given File
instance and optionally append to the file if it already exists.
|
SyncableFileOutputStream(FileDescriptor fdObj)
Creates an instance of SyncableFileOutputStream
using the given FileDescriptor instance.
|
SyncableFileOutputStream(String name)
Creates an instance of SyncableFileOutputStream with the
given name.
|
SyncableFileOutputStream(String name,
boolean append)
Creates an instance of SyncableFileOutputStream with the
given name and optionally append to the file if it already exists.
|
Modifier and Type | Method and Description |
---|---|
void |
sync()
Sync the file to disk.
|
close, finalize, getChannel, getFD, write, write, write
flush
public SyncableFileOutputStream(String name) throws FileNotFoundException
name
- - the full file name.FileNotFoundException
- - if the file cannot be created or opened.public SyncableFileOutputStream(File file) throws FileNotFoundException
file
- - The file to use to create the output stream.FileNotFoundException
- - if the file cannot be created or opened.public SyncableFileOutputStream(String name, boolean append) throws FileNotFoundException
name
- - the full file name.append
- - true if the file is to be appended toFileNotFoundException
- - if the file cannot be created or opened.public SyncableFileOutputStream(File file, boolean append) throws FileNotFoundException
file
- - the file instance to use to create the stream.append
- - true if the file is to be appended toFileNotFoundException
- - if the file cannot be created or opened.public SyncableFileOutputStream(FileDescriptor fdObj)
public void sync() throws IOException
fsync
and syncs all underlying OS buffers for this
file descriptor to disk. On these platforms, if this method returns,
the data written to this instance is guaranteed to be persisted on disk.sync
in interface Syncable
IOException
- - if an error occurred while attempting to sync the
data to disk.Copyright © 2009–2017 The Apache Software Foundation. All rights reserved.