ucar.unidata.io.http
Class HTTPRandomAccessFile

java.lang.Object
  extended by ucar.unidata.io.RandomAccessFile
      extended by ucar.unidata.io.http.HTTPRandomAccessFile
All Implemented Interfaces:
DataInput, DataOutput

public class HTTPRandomAccessFile
extends RandomAccessFile

Gives access to files over HTTP, using jakarta commons HttpClient library. This version uses a single instance of HttpClient, following performance guidelines at http://jakarta.apache.org/commons/httpclient/performance.html Plus other improvements.

Author:
John Caron

Field Summary
static int defaultHTTPBufferSize
           
 
Fields inherited from class ucar.unidata.io.RandomAccessFile
allFiles, BIG_ENDIAN, bigEndian, buffer, bufferStart, dataEnd, dataSize, debugAccess, debugLeaks, defaultBufferSize, endOfFile, file, fileChannel, filePosition, LITTLE_ENDIAN, location, openFiles, readonly, showOpen, showRead
 
Constructor Summary
HTTPRandomAccessFile(String url)
           
HTTPRandomAccessFile(String url, int bufferSize)
           
 
Method Summary
 void close()
           
 long length()
           
protected  int read_(long pos, byte[] buff, int offset, int len)
          Read directly from file, without going through the buffer.
 long readToByteChannel(WritableByteChannel dest, long offset, long nbytes)
           
 
Methods inherited from class ucar.unidata.io.RandomAccessFile
flush, getAllFiles, getBufferSize, getDebugLeaks, getDebugNbytes, getDebugNseeks, getFD, getFilePointer, getLocation, getOpenFiles, getRandomAccessFile, isAtEndOfFile, order, read, read, read, readBoolean, readBuffer, readByte, readBytes, readBytes, readChar, readDouble, readDouble, readFloat, readFloat, readFully, readFully, readInt, readInt, readIntUnbuffered, readLine, readLong, readLong, readShort, readShort, readString, readUnsignedByte, readUnsignedShort, readUTF, searchForward, seek, setBufferSize, setDebugAccess, setDebugLeaks, setExtendMode, setMinLength, skipBytes, toString, unread, write, write, write, writeBoolean, writeBoolean, writeByte, writeBytes, writeBytes, writeBytes, writeChar, writeChar, writeChars, writeDouble, writeDouble, writeFloat, writeFloat, writeInt, writeInt, writeLong, writeLong, writeShort, writeShort, writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultHTTPBufferSize

public static int defaultHTTPBufferSize
Constructor Detail

HTTPRandomAccessFile

public HTTPRandomAccessFile(String url)
                     throws IOException
Throws:
IOException

HTTPRandomAccessFile

public HTTPRandomAccessFile(String url,
                            int bufferSize)
                     throws IOException
Throws:
IOException
Method Detail

close

public void close()
Overrides:
close in class RandomAccessFile

read_

protected int read_(long pos,
                    byte[] buff,
                    int offset,
                    int len)
             throws IOException
Read directly from file, without going through the buffer. All reading goes through here or readToByteChannel;

Overrides:
read_ in class RandomAccessFile
Parameters:
pos - start here in the file
buff - put data into this buffer
offset - buffer offset
len - 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
Overrides:
readToByteChannel in class RandomAccessFile
Throws:
IOException

length

public long length()
            throws IOException
Overrides:
length in class RandomAccessFile
Throws:
IOException


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.