com.mucommander.file.impl.nfs
Class NFSFile.NFSRandomAccessOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.mucommander.io.RandomAccessOutputStream
          extended by com.mucommander.file.impl.nfs.NFSFile.NFSRandomAccessOutputStream
All Implemented Interfaces:
RandomAccess, java.io.Closeable, java.io.Flushable
Enclosing class:
NFSFile

public static class NFSFile.NFSRandomAccessOutputStream
extends RandomAccessOutputStream

NFSRandomAccessOutputStream extends RandomAccessOutputStream to provide random write access to an NFSFile.

Warning: this RandomAccessOutputStream is not fully functional, the setLength(long) has a limitation.


Constructor Summary
NFSFile.NFSRandomAccessOutputStream(com.sun.xfile.XRandomAccessFile raf)
           
 
Method Summary
 void close()
          Closes this stream and releases any system resources associated with the stream.
 long getLength()
          Returns the length of the file, in bytes.
 long getOffset()
          Returns the offset (in bytes) from the beginning of the file at which the next read or write occurs.
 void seek(long offset)
          Sets the offset, measured from the beginning of the file, at which the next read or write occurs.
 void setLength(long newLength)
          Warning: this method is only capable of expanding the file, not truncating it.
 void write(byte[] b)
          Writes b.length bytes from the specified byte array to this file, starting at the current file offset.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this file.
 void write(int i)
           
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NFSFile.NFSRandomAccessOutputStream

public NFSFile.NFSRandomAccessOutputStream(com.sun.xfile.XRandomAccessFile raf)
Method Detail

write

public void write(int i)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Description copied from class: RandomAccessOutputStream
Writes b.length bytes from the specified byte array to this file, starting at the current file offset.

Specified by:
write in class RandomAccessOutputStream
Parameters:
b - the data to write
Throws:
java.io.IOException - if an I/O error occurs

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Description copied from class: RandomAccessOutputStream
Writes len bytes from the specified byte array starting at offset off to this file.

Specified by:
write in class RandomAccessOutputStream
Parameters:
b - the data to write
off - the start offset in the data array
len - the number of bytes to write
Throws:
java.io.IOException - if an I/O error occurs

close

public void close()
           throws java.io.IOException
Description copied from class: RandomAccessOutputStream
Closes this stream and releases any system resources associated with the stream. A closed stream cannot perform output operations and cannot be reopened.

Specified by:
close in interface RandomAccess
Specified by:
close in interface java.io.Closeable
Specified by:
close in class RandomAccessOutputStream
Throws:
java.io.IOException - if an I/O error occurs.

getOffset

public long getOffset()
               throws java.io.IOException
Description copied from interface: RandomAccess
Returns the offset (in bytes) from the beginning of the file at which the next read or write occurs.

Returns:
the offset (in bytes) from the beginning of the file at which the next read or write occurs
Throws:
java.io.IOException - if an I/O error occurs.

getLength

public long getLength()
               throws java.io.IOException
Description copied from interface: RandomAccess
Returns the length of the file, in bytes.

Returns:
the length of the file, in bytes
Throws:
java.io.IOException - if an I/O error occurs

seek

public void seek(long offset)
          throws java.io.IOException
Description copied from interface: RandomAccess
Sets the offset, measured from the beginning of the file, at which the next read or write occurs. The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.

Parameters:
offset - the new offset position, measured in bytes from the beginning of the file
Throws:
java.io.IOException - if an I/O error occurs

setLength

public void setLength(long newLength)
               throws java.io.IOException
Warning: this method is only capable of expanding the file, not truncating it. It will throw an IOException whenever the newLength parameter is greater than the current length reported by getLength().

Specified by:
setLength in class RandomAccessOutputStream
Parameters:
newLength - the new file's length
Throws:
java.io.IOException - If an I/O error occurred while trying to change the file's length


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard