org.apache.lucene.store

## Class IndexOutput

- java.lang.Object
- - org.apache.lucene.store.IndexOutput

- Direct Known Subclasses:
    BufferedIndexOutput, ChecksumIndexOutput, DbIndexOutput, JEIndexOutput, RAMOutputStream

      public abstract class IndexOutput
      extends java.lang.Object

  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 and Description
    `IndexOutput()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `close()` Closes this stream to further operations.
    `void` | `copyBytes(IndexInput input, long numBytes)` Copy numBytes bytes from input to ourself.
    `abstract void` | `flush()` Forces any buffered output to be written.
    `abstract long` | `getFilePointer()` Returns the current position in this file, where the next write will occur.
    `abstract long` | `length()` The number of bytes in the file.
    `abstract void` | `seek(long pos)` Sets current position in this file, where the next write will occur.
    `void` | `setLength(long length)` Set the file length.
    `abstract void` | `writeByte(byte b)` Writes a single byte.
    `void` | `writeBytes(byte[] b, int length)` Writes an array of bytes.
    `abstract void` | `writeBytes(byte[] b, int offset, int length)` Writes an array of bytes.
    `void` | `writeChars(char[] s, int start, int length)` Deprecated. -- please pre-convert to utf8 bytes instead or use `writeString(java.lang.String)`
    `void` | `writeChars(java.lang.String s, int start, int length)` Deprecated. -- please pre-convert to utf8 bytes instead or use `writeString(java.lang.String)`
    `void` | `writeInt(int i)` Writes an int as four bytes.
    `void` | `writeLong(long i)` Writes a long as eight bytes.
    `void` | `writeString(java.lang.String s)` Writes a string.
    `void` | `writeStringStringMap(java.util.Map map)`
    `void` | `writeVInt(int i)` Writes an int in a variable-length format.
    `void` | `writeVLong(long i)` Writes an long in a variable-length format.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IndexOutput

          public IndexOutput()

  - ### Method Detail

    - #### writeByte

          public abstract void writeByte(byte b)
                                  throws java.io.IOException

      Writes a single byte.
      Throws:
        `java.io.IOException`
      See Also:
        `IndexInput.readByte()`

    - #### writeBytes

          public void writeBytes(byte[] b,
                                 int length)
                          throws java.io.IOException

      Writes an array of bytes.
      Parameters:
        `b` - the bytes to write
        `length` - the number of bytes to write
      Throws:
        `java.io.IOException`
      See Also:
        `IndexInput.readBytes(byte[],int,int)`

    - #### writeBytes

          public abstract void writeBytes(byte[] b,
                                          int offset,
                                          int length)
                                   throws java.io.IOException

      Writes an array of bytes.
      Parameters:
        `b` - the bytes to write
        `offset` - the offset in the byte array
        `length` - the number of bytes to write
      Throws:
        `java.io.IOException`
      See Also:
        `IndexInput.readBytes(byte[],int,int)`

    - #### writeInt

          public void writeInt(int i)
                        throws java.io.IOException

      Writes an int as four bytes.
      Throws:
        `java.io.IOException`
      See Also:
        `IndexInput.readInt()`

    - #### writeVInt

          public void writeVInt(int i)
                         throws java.io.IOException

      Writes an int in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.
      Throws:
        `java.io.IOException`
      See Also:
        `IndexInput.readVInt()`

    - #### writeLong

          public void writeLong(long i)
                         throws java.io.IOException

      Writes a long as eight bytes.
      Throws:
        `java.io.IOException`
      See Also:
        `IndexInput.readLong()`

    - #### writeVLong

          public void writeVLong(long i)
                          throws java.io.IOException

      Writes an long in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.
      Throws:
        `java.io.IOException`
      See Also:
        `IndexInput.readVLong()`

    - #### writeString

          public void writeString(java.lang.String s)
                           throws java.io.IOException

      Writes a string.
      Throws:
        `java.io.IOException`
      See Also:
        `IndexInput.readString()`

    - #### writeChars

          public void writeChars(java.lang.String s,
                                 int start,
                                 int length)
                          throws java.io.IOException

      Deprecated. -- please pre-convert to utf8 bytes instead or use `writeString(java.lang.String)`
      Writes a sub sequence of characters from s as the old format (modified UTF-8 encoded bytes).
      Parameters:
        `s` - the source of the characters
        `start` - the first character in the sequence
        `length` - the number of characters in the sequence
      Throws:
        `java.io.IOException`

    - #### writeChars

          public void writeChars(char[] s,
                                 int start,
                                 int length)
                          throws java.io.IOException

      Deprecated. -- please pre-convert to utf8 bytes instead or use `writeString(java.lang.String)`
      Writes a sub sequence of characters from char[] as the old format (modified UTF-8 encoded bytes).
      Parameters:
        `s` - the source of the characters
        `start` - the first character in the sequence
        `length` - the number of characters in the sequence
      Throws:
        `java.io.IOException`

    - #### copyBytes

          public void copyBytes(IndexInput input,
                                long numBytes)
                         throws java.io.IOException

      Copy numBytes bytes from input to ourself.
      Throws:
        `java.io.IOException`

    - #### flush

          public abstract void flush()
                              throws java.io.IOException

      Forces any buffered output to be written.
      Throws:
        `java.io.IOException`

    - #### close

          public abstract void close()
                              throws java.io.IOException

      Closes this stream to further operations.
      Throws:
        `java.io.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 java.io.IOException

      Sets current position in this file, where the next write will occur.
      Throws:
        `java.io.IOException`
      See Also:
        `getFilePointer()`

    - #### length

          public abstract long length()
                               throws java.io.IOException

      The number of bytes in the file.
      Throws:
        `java.io.IOException`

    - #### setLength

          public void setLength(long length)
                         throws java.io.IOException

      Set 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:
        `java.io.IOException`

    - #### writeStringStringMap

          public void writeStringStringMap(java.util.Map map)
                                    throws java.io.IOException

      Throws:
        `java.io.IOException`

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