Package ucar.unidata.io
Class RemoteRandomAccessFile
- java.lang.Object
-
- ucar.unidata.io.RandomAccessFile
-
- ucar.unidata.io.RemoteRandomAccessFile
-
- All Implemented Interfaces:
Closeable
,DataInput
,DataOutput
,AutoCloseable
,FileCacheable
,ReadableRemoteFile
- Direct Known Subclasses:
HTTPRandomAccessFile
,S3RandomAccessFile
public abstract class RemoteRandomAccessFile extends RandomAccessFile implements ReadableRemoteFile
An abstract superclass for remote RandomAccessFile
-
-
Field Summary
Fields Modifier and Type Field Description protected static long
defaultMaxReadCacheSize
protected static int
defaultRemoteFileBufferSize
protected static int
defaultRemoteFileTimeout
protected String
url
-
Fields inherited from class ucar.unidata.io.RandomAccessFile
allFiles, BIG_ENDIAN, bigEndian, buffer, bufferModified, bufferStart, dataEnd, dataSize, debugAccess, debugLeaks, defaultBufferSize, endOfFile, file, fileChannel, filePosition, LITTLE_ENDIAN, location, openFiles, readonly, showOpen, showRead
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RemoteRandomAccessFile(String url, int bufferSize, long maxRemoteCacheSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the file, and release any associated system resources.protected int
read_(long pos, byte[] buff, int offset, int len)
Read data into the buffer, and return number of bytes read.long
readToByteChannel(WritableByteChannel dest, long offset, long nbytes)
Readnbytes
bytes, at the specified file offset, send to a WritableByteChannel.-
Methods inherited from class ucar.unidata.io.RandomAccessFile
acquire, acquire, eject, enableDefaultGlobalFileCache, flush, getAllFiles, getBufferSize, getDebugLeaks, getDebugNbytes, getDebugNseeks, getFilePointer, getGlobalFileCache, getLastModified, getLocation, getMaxOpenFileCount, getOpenFileCount, getOpenFiles, getRandomAccessFile, isAtEndOfFile, isDirectory, length, order, order, reacquire, read, read, read, readBoolean, readBuffer, readByte, readBytes, readBytes, readChar, readDouble, readDouble, readFloat, readFloat, readFully, readFully, readInt, readInt, readIntUnbuffered, readLine, readLine, readLong, readLong, readShort, readShort, readString, readString, readStringMax, readStringMax, readUnsignedByte, readUnsignedShort, readUTF, release, searchForward, seek, setBufferSize, setDebugAccess, setDebugLeaks, setExtendMode, setFileCache, setGlobalFileCache, setMinLength, shutdown, skipBytes, skipBytes, toString, unread, write, write, write, writeBoolean, writeBoolean, writeByte, writeBytes, 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ucar.unidata.io.ReadableRemoteFile
closeRemote, readRemote
-
-
-
-
Field Detail
-
defaultMaxReadCacheSize
protected static final long defaultMaxReadCacheSize
- See Also:
- Constant Field Values
-
defaultRemoteFileBufferSize
protected static final int defaultRemoteFileBufferSize
- See Also:
- Constant Field Values
-
defaultRemoteFileTimeout
protected static final int defaultRemoteFileTimeout
- See Also:
- Constant Field Values
-
url
protected final String url
-
-
Constructor Detail
-
RemoteRandomAccessFile
protected RemoteRandomAccessFile(String url, int bufferSize, long maxRemoteCacheSize)
-
-
Method Detail
-
read_
protected int read_(long pos, byte[] buff, int offset, int len) throws IOException
Read data into the buffer, and return number of bytes read. If the read cache is enabled, the cache will be checked for data first. If not in the cache, data will be read directly from the remote service and placed in the cache. All reading goes through here or readToByteChannel;- Overrides:
read_
in classRandomAccessFile
- Parameters:
pos
- start here in the filebuff
- put data into this bufferoffset
- buffer offsetlen
- this number of bytes- Returns:
- actual number of bytes read
- Throws:
IOException
- on io error
-
readToByteChannel
public long readToByteChannel(WritableByteChannel dest, long offset, long nbytes) throws IOException
Description copied from class:RandomAccessFile
Readnbytes
bytes, at the specified file offset, send to a WritableByteChannel. This will block until all bytes are read. This uses the underlying file channel directly, bypassing all user buffers.- Overrides:
readToByteChannel
in classRandomAccessFile
- Parameters:
dest
- write to this WritableByteChannel.offset
- the offset in the file where copying will start.nbytes
- the number of bytes to read.- Returns:
- the actual number of bytes read and transfered
- Throws:
IOException
- if an I/O error occurs.
-
close
public void close() throws IOException
Description copied from class:RandomAccessFile
Close the file, and release any associated system resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFileCacheable
- Overrides:
close
in classRandomAccessFile
- Throws:
IOException
- if an I/O error occurrs.
-
-