22.2
java.io.DataOutput
THE PACKAGE JAVA.IO
22.2 The Interface
java.io.DataOutput
The
DataOutput
interface provides for converting data from any of the Java prim
itive types to a series of bytes and writing these bytes to a binary stream. There is
also a facility for converting a
String
into Java modified UTF 8 format and writ
ing the resulting series of bytes.
The
DataInput
interface ( 22.1) can be used to read in and reconstruct Java
data from the binary output data produced by the
DataOutput
interface.
The
DataOutput
interface is implemented by classes
DataOutputStream
( 22.21) and
RandomAccessFile
( 22.23).
public interface DataOutput {
public void write(int b) throws IOException;
public void write(byte[] b)
throws IOException, NullPointerException;
public void write(byte[] b, int off, int len)
throws IOException, NullPointerException,
IndexOutOfBoundsException;
public void writeBoolean(boolean v) throws IOException;
public void writeByte(int v) throws IOException;
public void writeShort(int v) throws IOException;
public void writeChar(int v) throws IOException;
public void writeInt(int v) throws IOException;
public void writeLong(long v) throws IOException;
public void writeFloat(float v) throws IOException;
public void writeDouble(double v) throws IOException;
public void writeBytes(String s)
throws IOException, NullPointerException;
public void writeChars(String s)
throws IOException, NullPointerException;
public void writeUTF(String s)
throws IOException, NullPointerException;
}
For all the methods in this interface that write bytes, it is generally true that if
a byte cannot be written for any reason, an
IOException
is thrown.
22.2.1
public void write(int b) throws IOException
The general contract for
write
is that one byte is written to the output stream. The
byte to be written is the eight low order bits of the argument
b
. The 24 high order
bits of
b
are ignored.
674
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved