Class DfsOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public abstract class DfsOutputStream
    extends java.io.OutputStream
    Output stream to create a file on the DFS.
    See Also:
    DfsObjDatabase.writeFile(DfsPackDescription, PackExt)
    • Constructor Summary

      Constructors 
      Constructor Description
      DfsOutputStream()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      int blockSize()
      Get the recommended alignment for writing.
      abstract int read​(long position, java.nio.ByteBuffer buf)
      Read back a portion of already written data.
      abstract void write​(byte[] buf, int off, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.OutputStream

        close, flush, nullOutputStream, write
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DfsOutputStream

        public DfsOutputStream()
    • Method Detail

      • blockSize

        public int blockSize()
        Get the recommended alignment for writing.

        Starting a write at multiples of the blockSize is more efficient than starting a write at any other position. If 0 or -1 the channel does not have any specific block size recommendation.

        Channels should not recommend large block sizes. Sizes up to 1-4 MiB may be reasonable, but sizes above that may be horribly inefficient.

        Returns:
        recommended alignment size for randomly positioned reads. Does not need to be a power of 2.
      • write

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

        public abstract void write​(byte[] buf,
                                   int off,
                                   int len)
                            throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • read

        public abstract int read​(long position,
                                 java.nio.ByteBuffer buf)
                          throws java.io.IOException
        Read back a portion of already written data.

        The writing position of the output stream is not affected by a read.

        Parameters:
        position - offset to read from.
        buf - buffer to populate. Up to buf.remaining() bytes will be read from position.
        Returns:
        number of bytes actually read.
        Throws:
        java.io.IOException - reading is not supported, or the read cannot be performed due to DFS errors.