Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.files.ui.resources
Class SystemSafeFileOutputStream


java.lang.Object
  extended by 

java.io.OutputStream
      extended by 
org.eclipse.rse.files.ui.resources.SystemSafeFileOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class SystemSafeFileOutputStream
extends OutputStream

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

destination

protected 
File destination

temp

protected 
File temp

output

protected 
OutputStream output

failed

protected boolean failed

BACKUP_EXTENSION

protected static final 
String BACKUP_EXTENSION
See Also:
Constant Field Values
Constructor Detail

SystemSafeFileOutputStream

public SystemSafeFileOutputStream(
File file)
                           throws 
IOException
Constructor for SystemSafeFileOutputStream.

Parameters:
file - the destination file.
Throws:
IOException

SystemSafeFileOutputStream

public SystemSafeFileOutputStream(
String destinationName)
                           throws 
IOException
Constructor for SystemSafeFileOutputStream.

Parameters:
destinationName - the destination file name
Throws:
IOException

SystemSafeFileOutputStream

public SystemSafeFileOutputStream(
String destinationPath,
                                  
String tempPath)
                           throws 
IOException
Constructor for SystemSafeFileOutputStream.

Parameters:
destinationPath - the destination file name
tempPath - the temporary file name
Throws:
IOException
Method Detail

close

public void close()
           throws 
IOException
Close the stream.

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

commit

protected void commit()
               throws 
IOException
Commit the temporary file to the destination.

Throws:
IOException

copy

protected void copy(
File sourceFile,
                    
File destinationFile)
             throws 
IOException
Copy contents of one file to another.

Parameters:
sourceFile - the source file
destinationFile - the destination file
Throws:
IOException

createTempFile

protected void createTempFile(
String tempPath)
                       throws 
IOException
Create the temporary file at the given path.

Parameters:
tempPath - the path of the temporary file to be created
Throws:
IOException

flush

public void flush()
           throws 
IOException
Flush the stream.

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

getTempFilePath

public 
String getTempFilePath()
Get the temporary file path.

Returns:
the path of the temporary file

transferData

protected void transferData(
InputStream source,
                            
OutputStream destination)
                     throws 
IOException
Transfers data from one stream to another.

Parameters:
source - stream
destination - stream
Throws:
IOException

write

public void write(int b)
           throws 
IOException
Write an integer.

Specified by:
write in class OutputStream
Parameters:
b - the integer to write
Throws:
IOException

RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire