Package org.apache.lucene.store
Class DataOutput
- java.lang.Object
-
- org.apache.lucene.store.DataOutput
-
- Direct Known Subclasses:
ByteArrayDataOutput
,IndexOutput
,OutputStreamDataOutput
,PagedBytes.PagedBytesDataOutput
public abstract class DataOutput extends Object
Abstract base class for performing write operations of Lucene's low-level data types.
-
-
Constructor Summary
Constructors Constructor Description DataOutput()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
copyBytes(DataInput input, long numBytes)
Copy numBytes bytes from input to ourself.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 usewriteString(java.lang.String)
void
writeChars(String s, int start, int length)
Deprecated.-- please pre-convert to utf8 bytes instead or usewriteString(java.lang.String)
void
writeInt(int i)
Writes an int as four bytes.void
writeLong(long i)
Writes a long as eight bytes.void
writeShort(short i)
Writes a short as two bytes.void
writeString(String s)
Writes a string.void
writeStringStringMap(Map<String,String> 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.
-
-
-
Method Detail
-
writeByte
public abstract void writeByte(byte b) throws IOException
Writes a single byte.- Throws:
IOException
- See Also:
DataInput.readByte()
-
writeBytes
public void writeBytes(byte[] b, int length) throws IOException
Writes an array of bytes.- Parameters:
b
- the bytes to writelength
- the number of bytes to write- Throws:
IOException
- See Also:
DataInput.readBytes(byte[],int,int)
-
writeBytes
public abstract void writeBytes(byte[] b, int offset, int length) throws IOException
Writes an array of bytes.- Parameters:
b
- the bytes to writeoffset
- the offset in the byte arraylength
- the number of bytes to write- Throws:
IOException
- See Also:
DataInput.readBytes(byte[],int,int)
-
writeInt
public void writeInt(int i) throws IOException
Writes an int as four bytes.- Throws:
IOException
- See Also:
DataInput.readInt()
-
writeShort
public void writeShort(short i) throws IOException
Writes a short as two bytes.- Throws:
IOException
- See Also:
DataInput.readShort()
-
writeVInt
public final void writeVInt(int i) throws IOException
Writes an int in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers are supported, but should be avoided.- Throws:
IOException
- See Also:
DataInput.readVInt()
-
writeLong
public void writeLong(long i) throws IOException
Writes a long as eight bytes.- Throws:
IOException
- See Also:
DataInput.readLong()
-
writeVLong
public final void writeVLong(long i) throws IOException
Writes an long in a variable-length format. Writes between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Throws:
IOException
- See Also:
DataInput.readVLong()
-
writeString
public void writeString(String s) throws IOException
Writes a string.- Throws:
IOException
- See Also:
DataInput.readString()
-
copyBytes
public void copyBytes(DataInput input, long numBytes) throws IOException
Copy numBytes bytes from input to ourself.- Throws:
IOException
-
writeChars
@Deprecated public void writeChars(String s, int start, int length) throws IOException
Deprecated.-- please pre-convert to utf8 bytes instead or usewriteString(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 charactersstart
- the first character in the sequencelength
- the number of characters in the sequence- Throws:
IOException
-
writeChars
@Deprecated public void writeChars(char[] s, int start, int length) throws IOException
Deprecated.-- please pre-convert to utf8 bytes instead or usewriteString(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 charactersstart
- the first character in the sequencelength
- the number of characters in the sequence- Throws:
IOException
-
writeStringStringMap
public void writeStringStringMap(Map<String,String> map) throws IOException
- Throws:
IOException
-
-