|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
com.mucommander.io.BackupOutputStream
public class BackupOutputStream
Saves file in as crash-safe a manner as possible.
In order to prevent system or muCommander failures to corrupt configuration files, the BackupOutputStream implements the following algorithm:
Files that have been saved by this class should be read with BackupInputStream
in order to make sure that an uncorrupt version of them is loaded.
The BackupOutputStream monitors all of its own I/O operations. If an error occurs, then the backup
operation will not be performed when close() is called. It's possible to force the backup operation by
using the close(boolean) method.
BackupInputStream| Field Summary | |
|---|---|
static char |
BACKUP_SUFFIX
Character to add suffix file names with in order to mark them as backup. |
| Constructor Summary | |
|---|---|
BackupOutputStream(AbstractFile file)
Opens a backup output stream on the specified file. |
|
BackupOutputStream(java.io.File file)
Opens a backup output stream on the specified file. |
|
BackupOutputStream(java.lang.String file)
Opens a backup output stream on the specified file. |
|
| Method Summary | |
|---|---|
void |
close()
Finishes the backup operation. |
void |
close(boolean backup)
Closes the output stream. |
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out to the stream. |
void |
write(byte[] b)
Writes b.length bytes to this output stream. |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array starting at offset off to this output stream. |
void |
write(int b)
Writes the specified byte to this output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char BACKUP_SUFFIX
| Constructor Detail |
|---|
public BackupOutputStream(java.io.File file)
throws java.io.IOException
file - file on which to open a backup output stream.
java.io.IOException - thrown if any IO error occurs.
public BackupOutputStream(java.lang.String file)
throws java.io.IOException
file - file on which to open a backup output stream.
java.io.IOException - thrown if any IO error occurs.
public BackupOutputStream(AbstractFile file)
throws java.io.IOException
file - file on which to open a backup output stream.
java.io.IOException - thrown if any IO error occurs.| Method Detail |
|---|
public void flush()
throws java.io.IOException
This method calls the flush() method of its underlying output stream.
If an error occurs at this point, the close() method will not overwrite the target file. This can be
forced through the close(boolean) method.
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOException - if an I/O error occurs.
public void write(byte[] b)
throws java.io.IOException
This method calls the write(byte[] b) method of its underlying output stream.
If an error occurs at this point, the close() method will not overwrite the target file. This can be
forced through the close(boolean) method.
write in class java.io.OutputStreamb - the data to be written.
java.io.IOException - if an I/O error occurs.
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
This method calls the write(byte[] b, int off, int len) method of its underlying output stream.
If an error occurs at this point, the close() method will not overwrite the target file. This can be
forced through the close(boolean) method.
write in class java.io.OutputStreamb - the data to be written.off - the start offset in the data.len - the number of bytes to write.
java.io.IOException - if an I/O error occurs.
public void write(int b)
throws java.io.IOException
This method calls the write(byte b) method of its underlying output stream.
If an error occurs at this point, the close() method will not overwrite the target file. This can be
forced through the close(boolean) method.
write in class java.io.OutputStreamb - the data to be written.
java.io.IOException - if an I/O error occurs.
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.OutputStreamjava.io.IOException - thrown if any IO related error occurs.
public void close(boolean backup)
throws java.io.IOException
The backup parameter is meant for those cases when an error happened
while writing to the stream: if it did, we don't want to propagate to the target
file, and thus should prevent the backup operation from being performed.
backup - whether or not to overwrite the target file by the backup one.
java.io.IOException - thrown if any IO related error occurs.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard