Methods Summary |
---|
public abstract void | close()Closes this stream to further operations.
|
public abstract void | flush()Forces any buffered output to be written.
|
public abstract long | getFilePointer()Returns the current position in this file, where the next write will
occur.
|
public abstract long | length()The number of bytes in the file.
|
public abstract void | seek(long pos)Sets current position in this file, where the next write will occur.
|
public abstract void | writeByte(byte b)Writes a single byte.
|
public void | writeBytes(byte[] b, int length)Writes an array of bytes.
writeBytes(b, 0, length);
|
public abstract void | writeBytes(byte[] b, int offset, int length)Writes an array of bytes.
|
public void | writeChars(java.lang.String s, int start, int length)Writes a sequence of UTF-8 encoded characters from a string.
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)));
}
}
|
public void | writeInt(int i)Writes an int as four bytes.
writeByte((byte)(i >> 24));
writeByte((byte)(i >> 16));
writeByte((byte)(i >> 8));
writeByte((byte) i);
|
public void | writeLong(long i)Writes a long as eight bytes.
writeInt((int) (i >> 32));
writeInt((int) i);
|
public void | writeString(java.lang.String s)Writes a string.
int length = s.length();
writeVInt(length);
writeChars(s, 0, length);
|
public void | writeVInt(int 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.
while ((i & ~0x7F) != 0) {
writeByte((byte)((i & 0x7f) | 0x80));
i >>>= 7;
}
writeByte((byte)i);
|
public void | writeVLong(long 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.
while ((i & ~0x7F) != 0) {
writeByte((byte)((i & 0x7f) | 0x80));
i >>>= 7;
}
writeByte((byte)i);
|