| Method from org.apache.lucene.store.OutputStream Detail: |
public void close() throws IOException {
flush();
}
Closes this stream to further operations. |
protected final void flush() throws IOException {
flushBuffer(buffer, bufferPosition);
bufferStart += bufferPosition;
bufferPosition = 0;
}
Forces any buffered output to be written. |
abstract protected void flushBuffer(byte[] b,
int len) throws IOException
Expert: implements buffer write. Writes bytes at the current position in
the output. |
public final long getFilePointer() throws IOException {
return bufferStart + bufferPosition;
}
Returns the current position in this file, where the next write will
occur. |
abstract public long length() throws IOException
The number of bytes in the file. |
public void seek(long pos) throws IOException {
flush();
bufferStart = pos;
}
Sets current position in this file, where the next write will occur. |
public final void writeByte(byte b) throws IOException {
if (bufferPosition >= BUFFER_SIZE)
flush();
buffer[bufferPosition++] = b;
}
|
public final void writeBytes(byte[] b,
int length) throws IOException {
for (int i = 0; i < length; i++)
writeByte(b[i]);
}
Writes an array of bytes. |
public final void writeChars(String s,
int start,
int length) throws IOException {
final int end = start + length;
for (int i = start; i < end; i++) {
final int code = (int)s.charAt(i);
if (code >= 0x01 && code < = 0x7F)
writeByte((byte)code);
else if (((code >= 0x80) && (code < = 0x7FF)) || code == 0) {
writeByte((byte)(0xC0 | (code > > 6)));
writeByte((byte)(0x80 | (code & 0x3F)));
} else {
writeByte((byte)(0xE0 | (code > > > 12)));
writeByte((byte)(0x80 | ((code > > 6) & 0x3F)));
writeByte((byte)(0x80 | (code & 0x3F)));
}
}
}
Writes a sequence of UTF-8 encoded characters from a string. |
public final void writeInt(int i) throws IOException {
writeByte((byte)(i > > 24));
writeByte((byte)(i > > 16));
writeByte((byte)(i > > 8));
writeByte((byte) i);
}
Writes an int as four bytes. |
public final void writeLong(long i) throws IOException {
writeInt((int) (i > > 32));
writeInt((int) i);
}
Writes a long as eight bytes. |
public final void writeString(String s) throws IOException {
int length = s.length();
writeVInt(length);
writeChars(s, 0, length);
}
|
public final void writeVInt(int i) throws IOException {
while ((i & ~0x7F) != 0) {
writeByte((byte)((i & 0x7f) | 0x80));
i > > >= 7;
}
writeByte((byte)i);
}
Writes an int in a variable-length format. Writes between one and
five bytes. Smaller values take fewer bytes. Negative numbers are not
supported. |
public final void writeVLong(long i) throws IOException {
while ((i & ~0x7F) != 0) {
writeByte((byte)((i & 0x7f) | 0x80));
i > > >= 7;
}
writeByte((byte)i);
}
Writes an long in a variable-length format. Writes between one and five
bytes. Smaller values take fewer bytes. Negative numbers are not
supported. |