org.apache.lucene.store

Class InputStream

public abstract class InputStream extends Object implements Cloneable

Abstract base class for input from a file in a {@link Directory}. A random-access input stream. Used for all Lucene index input operations.

See Also: Directory OutputStream

Field Summary
protected longlength
Method Summary
Objectclone()
Returns a clone of this stream.
abstract voidclose()
Closes the stream to futher operations.
longgetFilePointer()
Returns the current position in this file, where the next read will occur.
longlength()
The number of bytes in the file.
bytereadByte()
Reads and returns a single byte.
voidreadBytes(byte[] b, int offset, int len)
Reads a specified number of bytes into an array at the specified offset.
voidreadChars(char[] buffer, int start, int length)
Reads UTF-8 encoded characters into an array.
intreadInt()
Reads four bytes and returns an int.
protected abstract voidreadInternal(byte[] b, int offset, int length)
Expert: implements buffer refill.
longreadLong()
Reads eight bytes and returns a long.
StringreadString()
Reads a string.
intreadVInt()
Reads an int stored in variable-length format.
longreadVLong()
Reads a long stored in variable-length format.
voidseek(long pos)
Sets current position in this file, where the next read will occur.
protected abstract voidseekInternal(long pos)
Expert: implements seek.

Field Detail

length

protected long length

Method Detail

clone

public Object clone()
Returns a clone of this stream.

Clones of a stream access the same data, and are positioned at the same point as the stream they were cloned from.

Expert: Subclasses must ensure that clones may be positioned at different points in the input from each other and from the stream they were cloned from.

close

public abstract void close()
Closes the stream to futher operations.

getFilePointer

public final long getFilePointer()
Returns the current position in this file, where the next read will occur.

See Also: InputStream

length

public final long length()
The number of bytes in the file.

readByte

public final byte readByte()
Reads and returns a single byte.

See Also: OutputStream

readBytes

public final void readBytes(byte[] b, int offset, int len)
Reads a specified number of bytes into an array at the specified offset.

Parameters: b the array to read bytes into offset the offset in the array to start storing bytes len the number of bytes to read

See Also: (byte[],int)

readChars

public final void readChars(char[] buffer, int start, int length)
Reads UTF-8 encoded characters into an array.

Parameters: buffer the array to read characters into start the offset in the array to start storing characters length the number of characters to read

See Also: OutputStream

readInt

public final int readInt()
Reads four bytes and returns an int.

See Also: OutputStream

readInternal

protected abstract void readInternal(byte[] b, int offset, int length)
Expert: implements buffer refill. Reads bytes from the current position in the input.

Parameters: b the array to read bytes into offset the offset in the array to start storing bytes length the number of bytes to read

readLong

public final long readLong()
Reads eight bytes and returns a long.

See Also: OutputStream

readString

public final String readString()
Reads a string.

See Also: writeString

readVInt

public final int readVInt()
Reads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.

See Also: OutputStream

readVLong

public final long readVLong()
Reads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.

seek

public final void seek(long pos)
Sets current position in this file, where the next read will occur.

See Also: getFilePointer

seekInternal

protected abstract void seekInternal(long pos)
Expert: implements seek. Sets current position in this file, where the next {@link #readInternal(byte[],int,int)} will occur.

See Also: (byte[],int,int)

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.