artofillusion
Class SafeFileOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by artofillusion.SafeFileOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class SafeFileOutputStream
extends java.io.FilterOutputStream


Field Summary
static int APPEND
           
static int CREATE
           
static int KEEP_BACKUP
          optional modes
static int OVERWRITE
          Stream creation modes
 
Constructor Summary
SafeFileOutputStream(java.io.File file, int mode)
          Ctor Create a safe output stream on the specified file
SafeFileOutputStream(java.lang.String path, int mode)
          Ctor Create a safe output stream on the named path
 
Method Summary
 void abort()
          abort the stream closes the underlying stream, frees all resources, and removes any temporary files.
 void close()
          close the underlying stream, and complete the commit
 void open(java.io.File file, int mode)
          open the specified file
 void open(java.lang.String path, int mode)
          open the specified path
 void write(byte[] array)
          write to the underlying stream
 void write(byte[] array, int start, int length)
          write to the underlying stream
 void write(int value)
          write to the underlying stream
 
Methods inherited from class java.io.FilterOutputStream
flush
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OVERWRITE

public static final int OVERWRITE
Stream creation modes

See Also:
Constant Field Values

CREATE

public static final int CREATE
See Also:
Constant Field Values

APPEND

public static final int APPEND
See Also:
Constant Field Values

KEEP_BACKUP

public static final int KEEP_BACKUP
optional modes

See Also:
Constant Field Values
Constructor Detail

SafeFileOutputStream

public SafeFileOutputStream(java.lang.String path,
                            int mode)
                     throws java.io.IOException
Ctor Create a safe output stream on the named path

Parameters:
path - string pathname
mode - the logical OR of the desired mode values
Throws:
java.io.IOException

SafeFileOutputStream

public SafeFileOutputStream(java.io.File file,
                            int mode)
                     throws java.io.IOException
Ctor Create a safe output stream on the specified file

Parameters:
file - - File to write
mode - - logical OR of the desired mode values
Throws:
java.io.IOException
Method Detail

open

public void open(java.lang.String path,
                 int mode)
          throws java.io.IOException
open the specified path

Parameters:
path - String pathname of the output file
mode - logical OR of the desired mode values
Throws:
java.io.IOException

open

public void open(java.io.File file,
                 int mode)
          throws java.io.IOException
open the specified file

Parameters:
file - File to write
mode - logical OR of the desired mode values
Throws:
java.io.IOException

abort

public void abort()
           throws java.io.IOException
abort the stream closes the underlying stream, frees all resources, and removes any temporary files.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
close the underlying stream, and complete the commit

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(byte[] array)
           throws java.io.IOException
write to the underlying stream

Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(byte[] array,
                  int start,
                  int length)
           throws java.io.IOException
write to the underlying stream

Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(int value)
           throws java.io.IOException
write to the underlying stream

Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException


Copyright © 1999-2011 by Peter Eastman.