Package org.apache.lucene.store
Class IndexOutput
- java.lang.Object
-
- org.apache.lucene.store.DataOutput
-
- org.apache.lucene.store.IndexOutput
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
BufferedIndexOutput,ChecksumIndexOutput,RAMOutputStream
public abstract class IndexOutput extends DataOutput implements Closeable
Abstract base class for output to a file in a Directory. A random-access output stream. Used for all Lucene index output operations.- See Also:
Directory,IndexInput
-
-
Constructor Summary
Constructors Constructor Description IndexOutput()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidclose()Closes this stream to further operations.abstract voidflush()Forces any buffered output to be written.abstract longgetFilePointer()Returns the current position in this file, where the next write will occur.abstract longlength()The number of bytes in the file.abstract voidseek(long pos)Sets current position in this file, where the next write will occur.voidsetLength(long length)Set the file length.-
Methods inherited from class org.apache.lucene.store.DataOutput
copyBytes, writeByte, writeBytes, writeBytes, writeChars, writeChars, writeInt, writeLong, writeShort, writeString, writeStringStringMap, writeVInt, writeVLong
-
-
-
-
Method Detail
-
flush
public abstract void flush() throws IOExceptionForces any buffered output to be written.- Throws:
IOException
-
close
public abstract void close() throws IOExceptionCloses this stream to further operations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getFilePointer
public abstract long getFilePointer()
Returns the current position in this file, where the next write will occur.- See Also:
seek(long)
-
seek
public abstract void seek(long pos) throws IOExceptionSets current position in this file, where the next write will occur.- Throws:
IOException- See Also:
getFilePointer()
-
length
public abstract long length() throws IOExceptionThe number of bytes in the file.- Throws:
IOException
-
setLength
public void setLength(long length) throws IOExceptionSet the file length. By default, this method does nothing (it's optional for a Directory to implement it). But, certain Directory implementations (for example @see FSDirectory) can use this to inform the underlying IO system to pre-allocate the file to the specified size. If the length is longer than the current file length, the bytes added to the file are undefined. Otherwise the file is truncated.- Parameters:
length- file length- Throws:
IOException
-
-