|
RSE Release 3.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
org.eclipse.rse.files.ui.resources.SystemSafeFileOutputStream
public class SystemSafeFileOutputStream
This class should be used when there's a file already in the destination and we don't want to lose its contents if a failure writing this stream happens. Basically, the new contents are written to a temporary location. If everything goes OK, it is moved to the right place. The user has the option to define the temporary location or it will be created in the default-temporary directory
Field Summary | |
---|---|
protected static String |
BACKUP_EXTENSION
|
protected File |
destination
|
protected boolean |
failed
|
protected OutputStream |
output
|
protected File |
temp
|
Constructor Summary | |
---|---|
SystemSafeFileOutputStream(File file)
Constructor for SystemSafeFileOutputStream. |
|
SystemSafeFileOutputStream(String destinationName)
Constructor for SystemSafeFileOutputStream. |
|
SystemSafeFileOutputStream(String destinationPath,
String tempPath)
Constructor for SystemSafeFileOutputStream. |
Method Summary | |
---|---|
void |
close()
Close the stream. |
protected void |
commit()
Commit the temporary file to the destination. |
protected void |
copy(File sourceFile,
File destinationFile)
Copy contents of one file to another. |
protected void |
createTempFile(String tempPath)
Create the temporary file at the given path. |
void |
flush()
Flush the stream. |
String |
getTempFilePath()
Get the temporary file path. |
protected void |
transferData(InputStream source,
OutputStream destination)
Transfers data from one stream to another. |
void |
write(int b)
Write an integer. |
Methods inherited from class java.io.OutputStream |
---|
write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected File destination
protected File temp
protected OutputStream output
protected boolean failed
protected static final String BACKUP_EXTENSION
Constructor Detail |
---|
public SystemSafeFileOutputStream(File file) throws IOException
file
- the destination file.
IOException
public SystemSafeFileOutputStream(String destinationName) throws IOException
destinationName
- the destination file name
IOException
public SystemSafeFileOutputStream(String destinationPath, String tempPath) throws IOException
destinationPath
- the destination file nametempPath
- the temporary file name
IOException
Method Detail |
---|
public void close() throws IOException
close
in interface Closeable
close
in class OutputStream
IOException
protected void commit() throws IOException
IOException
protected void copy(File sourceFile, File destinationFile) throws IOException
sourceFile
- the source filedestinationFile
- the destination file
IOException
protected void createTempFile(String tempPath) throws IOException
tempPath
- the path of the temporary file to be created
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public String getTempFilePath()
protected void transferData(InputStream source, OutputStream destination) throws IOException
source
- streamdestination
- stream
IOException
public void write(int b) throws IOException
write
in class OutputStream
b
- the integer to write
IOException
|
RSE Release 3.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |