Class MemoryMappedRandomAccessFile

  • All Implemented Interfaces:
    Closeable, DataInput, DataOutput, AutoCloseable, FileCacheable

    public class MemoryMappedRandomAccessFile
    extends RandomAccessFile
    A ReadOnly MemoryMapped RandomAccessFile. It will map the file in memory, using a MappedByteBuffer.

    Writing capability is not supported at the moment.

    • Field Summary

      • Fields inherited from class RandomAccessFile

        allFiles, BIG_ENDIAN, bigEndian, buffer, bufferModified, bufferStart, dataEnd, dataSize, debugAccess, debugLeaks, defaultBufferSize, endOfFile, file, fileChannel, filePosition, LITTLE_ENDIAN, location, openFiles, readonly, showOpen, showRead
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      static String getUriString​(String uriString)  
      long length()  
      void reacquire()  
      int read()  
      int readBytes​(byte[] dst, int offset, int length)  
      void release()  
      boolean searchForward​(KMPMatch match, int maxBytes)  
      void seek​(long pos)  
      void setFileCache​(FileCacheIF fileCache)  
      void write​(int b)  
      void writeBytes​(byte[] dst, int offset, int length)  
      • Methods inherited from class RandomAccessFile

        acquire, acquire, eject, enableDefaultGlobalFileCache, flush, getAllFiles, getBufferSize, getDebugLeaks, getDebugNbytes, getDebugNseeks, getFilePointer, getGlobalFileCache, getLastModified, getLocation, getMaxOpenFileCount, getOpenFileCount, getOpenFiles, getRandomAccessFile, isAtEndOfFile, isDirectory, order, order, read, read, read_, readBoolean, readBuffer, readByte, readBytes, readChar, readDouble, readDouble, readFloat, readFloat, readFully, readFully, readInt, readInt, readIntUnbuffered, readLine, readLine, readLong, readLong, readShort, readShort, readString, readString, readStringMax, readStringMax, readToByteChannel, readUnsignedByte, readUnsignedShort, readUTF, setBufferSize, setDebugAccess, setDebugLeaks, setExtendMode, setGlobalFileCache, setMinLength, shutdown, skipBytes, skipBytes, toString, unread, write, write, writeBoolean, writeBoolean, writeByte, writeBytes, writeBytes, writeChar, writeChar, writeChar, writeChar, writeChar, writeChar, writeChars, writeChars, writeChars, writeDouble, writeDouble, writeDouble, writeDouble, writeDouble, writeDouble, writeFloat, writeFloat, writeFloat, writeFloat, writeFloat, writeFloat, writeInt, writeInt, writeInt, writeInt, writeInt, writeInt, writeLong, writeLong, writeLong, writeLong, writeLong, writeLong, writeShort, writeShort, writeShort, writeShort, writeShort, writeShort, writeUTF
      • Methods inherited from class Object

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

      • MemoryMappedRandomAccessFile

        public MemoryMappedRandomAccessFile​(String location,
                                            String mode)
                                     throws IOException
        Throws:
        IOException
    • Method Detail

      • seek

        public void seek​(long pos)
                  throws IOException
        Overrides:
        seek in class RandomAccessFile
        Throws:
        IOException
      • release

        public void release()
        Specified by:
        release in interface FileCacheable
        Overrides:
        release in class RandomAccessFile
      • reacquire

        public void reacquire()
        Specified by:
        reacquire in interface FileCacheable
        Overrides:
        reacquire in class RandomAccessFile
      • setFileCache

        public void setFileCache​(FileCacheIF fileCache)
        Specified by:
        setFileCache in interface FileCacheable
        Overrides:
        setFileCache in class RandomAccessFile
      • read

        public int read()
                 throws IOException
        Overrides:
        read in class RandomAccessFile
        Throws:
        IOException
      • readBytes

        public int readBytes​(byte[] dst,
                             int offset,
                             int length)
                      throws IOException
        Overrides:
        readBytes in class RandomAccessFile
        Throws:
        IOException
      • write

        public void write​(int b)
        Specified by:
        write in interface DataOutput
        Overrides:
        write in class RandomAccessFile
      • writeBytes

        public void writeBytes​(byte[] dst,
                               int offset,
                               int length)
        Overrides:
        writeBytes in class RandomAccessFile
      • length

        public long length()
        Overrides:
        length in class RandomAccessFile
      • close

        public void close()
                   throws IOException
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface FileCacheable
        Overrides:
        close in class RandomAccessFile
        Throws:
        IOException
      • getUriString

        public static String getUriString​(String uriString)
      • searchForward

        public boolean searchForward​(KMPMatch match,
                                     int maxBytes)
                              throws IOException
        Overrides:
        searchForward in class RandomAccessFile
        Throws:
        IOException