ch.javasoft.io
Class AbstractDataOutput
java.lang.Object
ch.javasoft.io.AbstractDataOutput
- All Implemented Interfaces:
- DataOutput
public abstract class AbstractDataOutput
- extends Object
- implements DataOutput
The AbstractDataOutput class implements most methods of
DataOutput, leaving only the following methods for subclasses:
This class is thread safe.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractDataOutput
public AbstractDataOutput()
write
public void write(byte[] b)
throws IOException
- Specified by:
write in interface DataOutput
- Throws:
IOException
writeBoolean
public void writeBoolean(boolean v)
throws IOException
- Specified by:
writeBoolean in interface DataOutput
- Throws:
IOException
writeByte
public void writeByte(int v)
throws IOException
- Specified by:
writeByte in interface DataOutput
- Throws:
IOException
writeBytes
public void writeBytes(String s)
throws IOException
- Specified by:
writeBytes in interface DataOutput
- Throws:
IOException
writeChar
public void writeChar(int v)
throws IOException
- Specified by:
writeChar in interface DataOutput
- Throws:
IOException
writeChars
public void writeChars(String s)
throws IOException
- Specified by:
writeChars in interface DataOutput
- Throws:
IOException
writeDouble
public void writeDouble(double v)
throws IOException
- Specified by:
writeDouble in interface DataOutput
- Throws:
IOException
writeFloat
public void writeFloat(float v)
throws IOException
- Specified by:
writeFloat in interface DataOutput
- Throws:
IOException
writeInt
public void writeInt(int v)
throws IOException
- Specified by:
writeInt in interface DataOutput
- Throws:
IOException
writeLong
public void writeLong(long v)
throws IOException
- Specified by:
writeLong in interface DataOutput
- Throws:
IOException
writeShort
public void writeShort(int v)
throws IOException
- Specified by:
writeShort in interface DataOutput
- Throws:
IOException
writeUTF
public void writeUTF(String str)
throws IOException
- Specified by:
writeUTF in interface DataOutput
- Throws:
IOException
writeUTF
protected static int writeUTF(String str,
AbstractDataOutput out)
throws IOException
- Copied from
DataOutputStream.writeUTF(String), but we use a
thread safe array instead.
Writes a string to the specified DataOutput using
modified UTF-8
encoding in a machine-independent manner.
First, two bytes are written to out as if by the writeShort
method giving the number of bytes to follow. This value is the number of
bytes actually written out, not the length of the string. Following the
length, each character of the string is output, in sequence, using the
modified UTF-8 encoding for the character. If no exception is thrown, the
counter written is incremented by the total number of
bytes written to the output stream. This will be at least two
plus the length of str, and at most two plus
thrice the length of str.
- Parameters:
str - a string to be written.out - destination to write to
- Returns:
- The number of bytes written out.
- Throws:
IOException - if an I/O error occurs.