Commit fddab7dc by Michael Koch Committed by Michael Koch

BufferedOutputStream.java, [...]: More merges from classpath.

2003-03-18  Michael Koch  <konqueror@gmx.de>

	* java/io/BufferedOutputStream.java,
	java/io/DataInput.java,
	java/io/DataInputStream.java,
	java/io/DataOutput.java,
	java/io/Externalizable.java:
	More merges from classpath.

From-SVN: r64528
parent 71a15b15
2003-03-18 Michael Koch <konqueror@gmx.de> 2003-03-18 Michael Koch <konqueror@gmx.de>
* java/io/BufferedOutputStream.java,
java/io/DataInput.java,
java/io/DataInputStream.java,
java/io/DataOutput.java,
java/io/Externalizable.java:
More merges from classpath.
2003-03-18 Michael Koch <konqueror@gmx.de>
* configure.in: Fixed links to platform dependant java.net files. * configure.in: Fixed links to platform dependant java.net files.
* configure: Regenerated. * configure: Regenerated.
* java/net/natInetAddress.cc, * java/net/natInetAddress.cc,
......
...@@ -46,65 +46,59 @@ package java.io; ...@@ -46,65 +46,59 @@ package java.io;
* efficient mechanism for writing versus doing numerous small unbuffered * efficient mechanism for writing versus doing numerous small unbuffered
* writes. * writes.
* *
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
*/ */
public class BufferedOutputStream extends FilterOutputStream public class BufferedOutputStream extends FilterOutputStream
{ {
/*
/*************************************************************************/
/*
* Class Variables * Class Variables
*/ */
/** /**
* This is the default buffer size * This is the default buffer size
*/ */
private static final int DEFAULT_BUFFER_SIZE = 512; private static final int DEFAULT_BUFFER_SIZE = 512;
/*************************************************************************/ /*************************************************************************/
/* /*
* Instance Variables * Instance Variables
*/ */
/** /**
* This is the internal byte array used for buffering output before * This is the internal byte array used for buffering output before
* writing it. * writing it.
*/ */
protected byte[] buf; protected byte[] buf;
/** /**
* This is the number of bytes that are currently in the buffer and * This is the number of bytes that are currently in the buffer and
* are waiting to be written to the underlying stream. It always points to * are waiting to be written to the underlying stream. It always points to
* the index into the buffer where the next byte of data will be stored * the index into the buffer where the next byte of data will be stored
*/ */
protected int count; protected int count;
/*************************************************************************/ /*************************************************************************/
/* /*
* Constructors * Constructors
*/ */
/** /**
* This method initializes a new <code>BufferedOutputStream</code> instance * This method initializes a new <code>BufferedOutputStream</code> instance
* that will write to the specified subordinate <code>OutputStream</code> * that will write to the specified subordinate <code>OutputStream</code>
* and which will use a default buffer size of 512 bytes. * and which will use a default buffer size of 512 bytes.
* *
* @param out The underlying <code>OutputStream</code> to write data to * @param out The underlying <code>OutputStream</code> to write data to
*/ */
public public BufferedOutputStream(OutputStream out)
BufferedOutputStream(OutputStream out) {
{
this(out, DEFAULT_BUFFER_SIZE); this(out, DEFAULT_BUFFER_SIZE);
} }
/*************************************************************************/ /*************************************************************************/
/** /**
* This method initializes a new <code>BufferedOutputStream</code> instance * This method initializes a new <code>BufferedOutputStream</code> instance
* that will write to the specified subordinate <code>OutputStream</code> * that will write to the specified subordinate <code>OutputStream</code>
* and which will use the specified buffer size * and which will use the specified buffer size
...@@ -112,71 +106,67 @@ BufferedOutputStream(OutputStream out) ...@@ -112,71 +106,67 @@ BufferedOutputStream(OutputStream out)
* @param out The underlying <code>OutputStream</code> to write data to * @param out The underlying <code>OutputStream</code> to write data to
* @param size The size of the internal buffer * @param size The size of the internal buffer
*/ */
public public BufferedOutputStream(OutputStream out, int size)
BufferedOutputStream(OutputStream out, int size) {
{
super(out); super(out);
buf = new byte[size]; buf = new byte[size];
} }
/*************************************************************************/ /*************************************************************************/
/* /*
* Instance Methods * Instance Methods
*/ */
/** /**
* This method causes any currently buffered bytes to be immediately * This method causes any currently buffered bytes to be immediately
* written to the underlying output stream. * written to the underlying output stream.
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public synchronized void public synchronized void flush() throws IOException
flush() throws IOException {
{
if (count == 0) if (count == 0)
return; return;
out.write(buf, 0, count); out.write(buf, 0, count);
count = 0; count = 0;
out.flush(); out.flush();
} }
/*************************************************************************/ /*************************************************************************/
/* /*
* This method flushes any remaining buffered bytes then closes the * This method flushes any remaining buffered bytes then closes the
* underlying output stream. Any further attempts to write to this stream * underlying output stream. Any further attempts to write to this stream
* may throw an exception * may throw an exception
* *
public synchronized void public synchronized void close() throws IOException
close() throws IOException {
{
flush(); flush();
out.close(); out.close();
} }
*/ */
/*************************************************************************/ /*************************************************************************/
/* /*
* This method runs when the object is garbage collected. It is * This method runs when the object is garbage collected. It is
* responsible for ensuring that all buffered bytes are written and * responsible for ensuring that all buffered bytes are written and
* for closing the underlying stream. * for closing the underlying stream.
* *
* @exception IOException If an error occurs (ignored by the Java runtime) * @exception IOException If an error occurs (ignored by the Java runtime)
* *
protected void protected void finalize() throws IOException
finalize() throws IOException {
{
close(); close();
} }
*/ */
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a single byte of data. This will be written to the * This method writes a single byte of data. This will be written to the
* buffer instead of the underlying data source. However, if the buffer * buffer instead of the underlying data source. However, if the buffer
* is filled as a result of this write request, it will be flushed to the * is filled as a result of this write request, it will be flushed to the
...@@ -186,19 +176,18 @@ finalize() throws IOException ...@@ -186,19 +176,18 @@ finalize() throws IOException
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public synchronized void public synchronized void write(int b) throws IOException
write(int b) throws IOException {
{
if (count == buf.length) if (count == buf.length)
flush(); flush();
buf[count] = (byte)(b & 0xFF); buf[count] = (byte)(b & 0xFF);
++count; ++count;
} }
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes <code>len</code> bytes from the byte array * This method writes <code>len</code> bytes from the byte array
* <code>buf</code> starting at position <code>offset</code> in the buffer. * <code>buf</code> starting at position <code>offset</code> in the buffer.
* These bytes will be written to the internal buffer. However, if this * These bytes will be written to the internal buffer. However, if this
...@@ -211,9 +200,9 @@ write(int b) throws IOException ...@@ -211,9 +200,9 @@ write(int b) throws IOException
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public synchronized void public synchronized void write(byte[] buf, int offset, int len)
write(byte[] buf, int offset, int len) throws IOException throws IOException
{ {
// Buffer can hold everything. Note that the case where LEN < 0 // Buffer can hold everything. Note that the case where LEN < 0
// is automatically handled by the downstream write. // is automatically handled by the downstream write.
if (len < (this.buf.length - count)) if (len < (this.buf.length - count))
...@@ -229,6 +218,7 @@ write(byte[] buf, int offset, int len) throws IOException ...@@ -229,6 +218,7 @@ write(byte[] buf, int offset, int len) throws IOException
flush(); flush();
out.write (buf, offset, len); out.write (buf, offset, len);
} }
} }
} // class BufferedOutputStream } // class BufferedOutputStream
/* DataInput.java -- Interface for reading data from a stream /* DataInput.java -- Interface for reading data from a stream
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -41,8 +41,7 @@ package java.io; ...@@ -41,8 +41,7 @@ package java.io;
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
* "The Java Language Specification", ISBN 0-201-63451-1 * "The Java Language Specification", ISBN 0-201-63451-1
* plus online API docs for JDK 1.2 beta from http://www.javasoft.com. * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
* Status: Believed complete and correct. * Status: Believed complete and correct. */
*/
/** /**
* This interface is implemented by classes that can data from streams * This interface is implemented by classes that can data from streams
...@@ -54,7 +53,7 @@ package java.io; ...@@ -54,7 +53,7 @@ package java.io;
public interface DataInput public interface DataInput
{ {
/** /**
* This method reads a Java boolean value from an input stream. It does * This method reads a Java boolean value from an input stream. It does
* so by reading a single byte of data. If that byte is zero, then the * so by reading a single byte of data. If that byte is zero, then the
* value returned is <code>false</code>. If the byte is non-zero, then * value returned is <code>false</code>. If the byte is non-zero, then
...@@ -66,15 +65,15 @@ public interface DataInput ...@@ -66,15 +65,15 @@ public interface DataInput
* *
* @return The <code>boolean</code> value read * @return The <code>boolean</code> value read
* *
* @exception EOFException If end of file is reached before reading the boolean * @exception EOFException If end of file is reached before
* reading the boolean
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
*/ */
boolean boolean readBoolean() throws EOFException, IOException;
readBoolean() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads a Java byte value from an input stream. The value * This method reads a Java byte value from an input stream. The value
* is in the range of -128 to 127. * is in the range of -128 to 127.
* <p> * <p>
...@@ -89,16 +88,16 @@ readBoolean() throws EOFException, IOException; ...@@ -89,16 +88,16 @@ readBoolean() throws EOFException, IOException;
* *
* @see DataOutput * @see DataOutput
*/ */
byte byte readByte() throws EOFException, IOException;
readByte() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads 8 unsigned bits into a Java <code>int</code> value from * This method reads 8 unsigned bits into a Java <code>int</code> value from
* the stream. The value returned is in the range of 0 to 255. * the stream. The value returned is in the range of 0 to 255.
* <p> * <p>
* This method can read an unsigned byte written by an object implementing the * This method can read an unsigned byte written by an object
* implementing the
* <code>writeUnsignedByte()</code> method in the <code>DataOutput</code> * <code>writeUnsignedByte()</code> method in the <code>DataOutput</code>
* interface. * interface.
* *
...@@ -109,12 +108,11 @@ readByte() throws EOFException, IOException; ...@@ -109,12 +108,11 @@ readByte() throws EOFException, IOException;
* *
* @see DataOutput * @see DataOutput
*/ */
int int readUnsignedByte() throws EOFException, IOException;
readUnsignedByte() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads a Java <code>char</code> value from an input stream. * This method reads a Java <code>char</code> value from an input stream.
* It operates by reading two bytes from the stream and converting them to * It operates by reading two bytes from the stream and converting them to
* a single 16-bit Java <code>char</code>. The two bytes are stored most * a single 16-bit Java <code>char</code>. The two bytes are stored most
...@@ -138,12 +136,11 @@ readUnsignedByte() throws EOFException, IOException; ...@@ -138,12 +136,11 @@ readUnsignedByte() throws EOFException, IOException;
* *
* @see DataOutput * @see DataOutput
*/ */
char char readChar() throws EOFException, IOException;
readChar() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads a signed 16-bit value into a Java in from the stream. * This method reads a signed 16-bit value into a Java in from the stream.
* It operates by reading two bytes from the stream and converting them to * It operates by reading two bytes from the stream and converting them to
* a single 16-bit Java <code>short</code>. The two bytes are stored most * a single 16-bit Java <code>short</code>. The two bytes are stored most
...@@ -158,7 +155,8 @@ readChar() throws EOFException, IOException; ...@@ -158,7 +155,8 @@ readChar() throws EOFException, IOException;
* <p> * <p>
* The value returned is in the range of -32768 to 32767. * The value returned is in the range of -32768 to 32767.
* <p> * <p>
* This method can read a <code>short</code> written by an object implementing * This method can read a <code>short</code> written by an object
* implementing
* the <code>writeShort()</code> method in the <code>DataOutput</code> * the <code>writeShort()</code> method in the <code>DataOutput</code>
* interface. * interface.
* *
...@@ -169,12 +167,11 @@ readChar() throws EOFException, IOException; ...@@ -169,12 +167,11 @@ readChar() throws EOFException, IOException;
* *
* @see DataOutput * @see DataOutput
*/ */
short short readShort() throws EOFException, IOException;
readShort() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads 16 unsigned bits into a Java int value from the stream. * This method reads 16 unsigned bits into a Java int value from the stream.
* It operates by reading two bytes from the stream and converting them to * It operates by reading two bytes from the stream and converting them to
* a single Java <code>int</code>. The two bytes are stored most * a single Java <code>int</code>. The two bytes are stored most
...@@ -190,20 +187,21 @@ readShort() throws EOFException, IOException; ...@@ -190,20 +187,21 @@ readShort() throws EOFException, IOException;
* The value returned is in the range of 0 to 65535. * The value returned is in the range of 0 to 65535.
* <p> * <p>
* This method can read an unsigned short written by an object implementing * This method can read an unsigned short written by an object implementing
* the <code>writeUnsignedShort()</code> method in the <code>DataOutput</code> * the <code>writeUnsignedShort()</code> method in the
* <code>DataOutput</code>
* interface. * interface.
* *
* @return The unsigned short value read as a Java <code>int</code>. * @return The unsigned short value read as a Java <code>int</code>.
* *
* @exception EOFException If end of file is reached before reading the value * @exception EOFException If end of file is reached before reading
* the value
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
*/ */
int int readUnsignedShort() throws EOFException, IOException;
readUnsignedShort() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads a Java <code>int</code> value from an input stream * This method reads a Java <code>int</code> value from an input stream
* It operates by reading four bytes from the stream and converting them to * It operates by reading four bytes from the stream and converting them to
* a single Java <code>int</code>. The bytes are stored most * a single Java <code>int</code>. The bytes are stored most
...@@ -216,10 +214,11 @@ readUnsignedShort() throws EOFException, IOException; ...@@ -216,10 +214,11 @@ readUnsignedShort() throws EOFException, IOException;
* <p> * <p>
* <code>(int)((byte1 << 24) + (byte2 << 16) + (byte3 << 8) + byte4))</code> * <code>(int)((byte1 << 24) + (byte2 << 16) + (byte3 << 8) + byte4))</code>
* <p> * <p>
The value returned is in the range of -2147483648 to 2147483647. * The value returned is in the range of -2147483648 to 2147483647.
* <p> * <p>
* This method can read an <code>int</code> written by an object implementing * This method can read an <code>int</code> written by an object
* the <code>writeInt()</code> method in the <code>DataOutput</code> interface. * implementing the <code>writeInt()</code> method in the
* <code>DataOutput</code> interface.
* *
* @return The <code>int</code> value read * @return The <code>int</code> value read
* *
...@@ -228,12 +227,11 @@ readUnsignedShort() throws EOFException, IOException; ...@@ -228,12 +227,11 @@ readUnsignedShort() throws EOFException, IOException;
* *
* @see DataOutput * @see DataOutput
*/ */
int int readInt() throws EOFException, IOException;
readInt() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads a Java <code>long</code> value from an input stream * This method reads a Java <code>long</code> value from an input stream
* It operates by reading eight bytes from the stream and converting them to * It operates by reading eight bytes from the stream and converting them to
* a single Java <code>long</code>. The bytes are stored most * a single Java <code>long</code>. The bytes are stored most
...@@ -251,9 +249,9 @@ readInt() throws EOFException, IOException; ...@@ -251,9 +249,9 @@ readInt() throws EOFException, IOException;
* The value returned is in the range of -9223372036854775808 to * The value returned is in the range of -9223372036854775808 to
* 9223372036854775807. * 9223372036854775807.
* <p> * <p>
* This method can read an <code>long</code> written by an object implementing * This method can read an <code>long</code> written by an object
* the <code>writeLong()</code> method in the <code>DataOutput</code> * implementing the <code>writeLong()</code> method in the
* interface. * <code>DataOutput</code> interface.
* *
* @return The <code>long</code> value read * @return The <code>long</code> value read
* *
...@@ -262,12 +260,11 @@ readInt() throws EOFException, IOException; ...@@ -262,12 +260,11 @@ readInt() throws EOFException, IOException;
* *
* @see DataOutput * @see DataOutput
*/ */
long long readLong() throws EOFException, IOException;
readLong() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads a Java float value from an input stream. It operates * This method reads a Java float value from an input stream. It operates
* by first reading an <code>int</code> value from the stream by calling the * by first reading an <code>int</code> value from the stream by calling the
* <code>readInt()</code> method in this interface, then converts that * <code>readInt()</code> method in this interface, then converts that
...@@ -275,24 +272,25 @@ readLong() throws EOFException, IOException; ...@@ -275,24 +272,25 @@ readLong() throws EOFException, IOException;
* <code>intBitsToFloat</code> method in the class * <code>intBitsToFloat</code> method in the class
* <code>java.lang.Float</code>. * <code>java.lang.Float</code>.
* <p> * <p>
* This method can read a <code>float</code> written by an object implementing * This method can read a <code>float</code> written by an object
* implementing
* the <code>writeFloat()</code> method in the <code>DataOutput</code> * the <code>writeFloat()</code> method in the <code>DataOutput</code>
* interface. * interface.
* *
* @return The <code>float</code> value read * @return The <code>float</code> value read
* *
* @exception EOFException If end of file is reached before reading the float * @exception EOFException If end of file is reached before reading the
* float
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
* *
* @see java.lang.Float * @see java.lang.Float
* @see DataOutput * @see DataOutput
*/ */
float float readFloat() throws EOFException, IOException;
readFloat() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads a Java double value from an input stream. It operates * This method reads a Java double value from an input stream. It operates
* by first reading a <code>long</code> value from the stream by calling the * by first reading a <code>long</code> value from the stream by calling the
* <code>readLong()</code> method in this interface, then converts that * <code>readLong()</code> method in this interface, then converts that
...@@ -306,26 +304,28 @@ readFloat() throws EOFException, IOException; ...@@ -306,26 +304,28 @@ readFloat() throws EOFException, IOException;
* *
* @return The <code>double</code> value read * @return The <code>double</code> value read
* *
* @exception EOFException If end of file is reached before reading the double * @exception EOFException If end of file is reached before reading the
* double
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
* *
* @see java.lang.Double * @see java.lang.Double
* @see DataOutput * @see DataOutput
*/ */
double double readDouble() throws EOFException, IOException;
readDouble() throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads the next line of text data from an input stream. * This method reads the next line of text data from an input stream.
* It operates by reading bytes and converting those bytes to <code>char</code> * It operates by reading bytes and converting those bytes to
* <code>char</code>
* values by treating the byte read as the low eight bits of the * values by treating the byte read as the low eight bits of the
* <code>char</code> and using 0 as the high eight bits. Because of this, * <code>char</code> and using 0 as the high eight bits. Because of this,
* it does not support the full 16-bit Unicode character set. * it does not support the full 16-bit Unicode character set.
* <P> * <P>
* The reading of bytes ends when either the end of file or a line terminator * The reading of bytes ends when either the end of file or a line terminator
* is encountered. The bytes read are then returned as a <code>String</code>. * is encountered. The bytes read are then returned as a
* <code>String</code>.
* A line terminator is a byte sequence consisting of either * A line terminator is a byte sequence consisting of either
* <code>\r</code>, <code>\n</code> or <code>\r\n</code>. These termination * <code>\r</code>, <code>\n</code> or <code>\r\n</code>. These termination
* charaters are discarded and are not returned as part of the string. * charaters are discarded and are not returned as part of the string.
...@@ -339,22 +339,22 @@ readDouble() throws EOFException, IOException; ...@@ -339,22 +339,22 @@ readDouble() throws EOFException, IOException;
* *
* @see DataOutput * @see DataOutput
*/ */
String String readLine() throws IOException;
readLine() throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads a <code>String</code> from an input stream that is * This method reads a <code>String</code> from an input stream that is
* encoded in a modified UTF-8 format. This format has a leading two byte * encoded in a modified UTF-8 format. This format has a leading two byte
* sequence that contains the remaining number of bytes to read. This two byte * sequence that contains the remaining number of bytes to read.
* This two byte
* sequence is read using the <code>readUnsignedShort()</code> method of this * sequence is read using the <code>readUnsignedShort()</code> method of this
* interface. * interface.
* *
* After the number of remaining bytes have been determined, these bytes * After the number of remaining bytes have been determined, these bytes
* are read an transformed into <code>char</code> values. These * are read an transformed into <code>char</code> values. These
* <code>char</code> values are encoded in the stream using either a one, two, * <code>char</code> values are encoded in the stream using either a one,
* or three byte format. * two, or three byte format.
* The particular format in use can be determined by examining the first * The particular format in use can be determined by examining the first
* byte read. * byte read.
* <p> * <p>
...@@ -398,27 +398,27 @@ readLine() throws IOException; ...@@ -398,27 +398,27 @@ readLine() throws IOException;
* *
* Note that all characters are encoded in the method that requires the * Note that all characters are encoded in the method that requires the
* fewest number of bytes with the exception of the character with the * fewest number of bytes with the exception of the character with the
* value of <code>\<llll>u0000</code> which is encoded as two bytes. This is * value of <code>\<llll>u0000</code> which is encoded as two bytes.
* a modification of the UTF standard used to prevent C language style * This is a modification of the UTF standard used to prevent C language
* <code>NUL</code> values from appearing in the byte stream. * style <code>NUL</code> values from appearing in the byte stream.
* <p> * <p>
* This method can read data that was written by an object implementing the * This method can read data that was written by an object implementing the
* <code>writeUTF()</code> method in <code>DataOutput</code>. * <code>writeUTF()</code> method in <code>DataOutput</code>.
* *
* @returns The <code>String</code> read * @returns The <code>String</code> read
* *
* @exception EOFException If end of file is reached before reading the String * @exception EOFException If end of file is reached before reading the
* String
* @exception UTFDataFormatException If the data is not in UTF-8 format * @exception UTFDataFormatException If the data is not in UTF-8 format
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
* *
* @see DataOutput * @see DataOutput
*/ */
String String readUTF() throws EOFException, UTFDataFormatException, IOException;
readUTF() throws EOFException, UTFDataFormatException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads raw bytes into the passed array until the array is * This method reads raw bytes into the passed array until the array is
* full. Note that this method blocks until the data is available and * full. Note that this method blocks until the data is available and
* throws an exception if there is not enough data left in the stream to * throws an exception if there is not enough data left in the stream to
...@@ -426,17 +426,19 @@ readUTF() throws EOFException, UTFDataFormatException, IOException; ...@@ -426,17 +426,19 @@ readUTF() throws EOFException, UTFDataFormatException, IOException;
* *
* @param buf The buffer into which to read the data * @param buf The buffer into which to read the data
* *
* @exception EOFException If end of file is reached before filling the buffer * @exception EOFException If end of file is reached before filling the
* buffer
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
*/ */
void void readFully(byte[] buf) throws EOFException, IOException;
readFully(byte[] buf) throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method reads raw bytes into the passed array <code>buf</code> starting * This method reads raw bytes into the passed array <code>buf</code>
* <code>offset</code> bytes into the buffer. The number of bytes read will be * starting
* <code>offset</code> bytes into the buffer. The number of bytes read
* will be
* exactly <code>len</code>. Note that this method blocks until the data is * exactly <code>len</code>. Note that this method blocks until the data is
* available and * throws an exception if there is not enough data left in * available and * throws an exception if there is not enough data left in
* the stream to read <code>len</code> bytes. * the stream to read <code>len</code> bytes.
...@@ -445,15 +447,16 @@ readFully(byte[] buf) throws EOFException, IOException; ...@@ -445,15 +447,16 @@ readFully(byte[] buf) throws EOFException, IOException;
* @param offset The offset into the buffer to start storing data * @param offset The offset into the buffer to start storing data
* @param len The number of bytes to read into the buffer * @param len The number of bytes to read into the buffer
* *
* @exception EOFException If end of file is reached before filling the buffer * @exception EOFException If end of file is reached before filling the
* buffer
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
*/ */
void void readFully(byte[] buf, int offset, int len)
readFully(byte[] buf, int offset, int len) throws EOFException, IOException; throws EOFException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method skips and discards the specified number of bytes in an * This method skips and discards the specified number of bytes in an
* input stream * input stream
* *
...@@ -466,7 +469,6 @@ readFully(byte[] buf, int offset, int len) throws EOFException, IOException; ...@@ -466,7 +469,6 @@ readFully(byte[] buf, int offset, int len) throws EOFException, IOException;
* skipped * skipped
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
*/ */
int int skipBytes(int n) throws EOFException, IOException;
skipBytes(int n) throws EOFException, IOException;
} // interface DataInput } // interface DataInput
/* DataInputStream.java -- FilteredInputStream that implements DataInput /* DataInputStream.java -- FilteredInputStream that implements DataInput
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -50,8 +50,6 @@ package java.io; ...@@ -50,8 +50,6 @@ package java.io;
* *
* @see DataInput * @see DataInput
* *
* @version 0.0
*
* @author Warren Levy <warrenl@cygnus.com> * @author Warren Levy <warrenl@cygnus.com>
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
* @date October 20, 1998. * @date October 20, 1998.
......
...@@ -53,127 +53,117 @@ package java.io; ...@@ -53,127 +53,117 @@ package java.io;
public interface DataOutput public interface DataOutput
{ {
/** /**
* This method writes a Java boolean value to an output stream * This method writes a Java boolean value to an output stream
* *
* @param value The boolean value to write * @param value The boolean value to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeBoolean(boolean value) throws IOException;
writeBoolean(boolean value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a Java byte value to an output stream * This method writes a Java byte value to an output stream
* *
* @param value The int value to write * @param value The int value to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeByte(int value) throws IOException;
writeByte(int value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a Java char value to an output stream * This method writes a Java char value to an output stream
* *
* @param value The char value to write * @param value The char value to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeChar(int value) throws IOException;
writeChar(int value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a Java int value to an output stream as a 16 bit value * This method writes a Java int value to an output stream as a 16 bit value
* *
* @param value The int value to write as a 16-bit value * @param value The int value to write as a 16-bit value
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeShort(int value) throws IOException;
writeShort(int value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a Java int value to an output stream * This method writes a Java int value to an output stream
* *
* @param value The int value to write * @param value The int value to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeInt(int value) throws IOException;
writeInt(int value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a Java long value to an output stream * This method writes a Java long value to an output stream
* *
* @param value The long value to write * @param value The long value to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeLong(long value) throws IOException;
writeLong(long value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a Java float value to an output stream * This method writes a Java float value to an output stream
* *
* @param value The float value to write * @param value The float value to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeFloat(float value) throws IOException;
writeFloat(float value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a Java double value to an output stream * This method writes a Java double value to an output stream
* *
* @param value The double value to write * @param value The double value to write
* *
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
*/ */
void void writeDouble(double value) throws IOException;
writeDouble(double value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a String to an output stream as an array of bytes * This method writes a String to an output stream as an array of bytes
* *
* @param value The String to write * @param value The String to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeBytes(String value) throws IOException;
writeBytes(String value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a String to an output stream as an array of char's * This method writes a String to an output stream as an array of char's
* *
* @param value The String to write * @param value The String to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeChars(String value) throws IOException;
writeChars(String value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes a String to an output stream encoded in * This method writes a String to an output stream encoded in
* UTF-8 format. * UTF-8 format.
* *
...@@ -181,12 +171,11 @@ writeChars(String value) throws IOException; ...@@ -181,12 +171,11 @@ writeChars(String value) throws IOException;
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void writeUTF(String value) throws IOException;
writeUTF(String value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes an 8-bit value (passed into the method as a Java * This method writes an 8-bit value (passed into the method as a Java
* int) to an output stream. * int) to an output stream.
* *
...@@ -194,35 +183,35 @@ writeUTF(String value) throws IOException; ...@@ -194,35 +183,35 @@ writeUTF(String value) throws IOException;
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void write(int value) throws IOException;
write(int value) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes the raw byte array passed in to the output stream. * This method writes the raw byte array passed in to the output stream.
* *
* @param buf The byte array to write * @param buf The byte array to write
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
void void write(byte[] buf) throws IOException;
write(byte[] buf) throws IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method writes raw bytes from the passed array <code>buf</code> starting * This method writes raw bytes from the passed array <code>buf</code>
* <code>offset</code> bytes into the buffer. The number of bytes written will be * starting
* exactly <code>len</code>. * <code>offset</code> bytes into the buffer. The number of bytes
* written will be * exactly <code>len</code>.
* *
* @param buf The buffer from which to write the data * @param buf The buffer from which to write the data
* @param offset The offset into the buffer to start writing data from * @param offset The offset into the buffer to start writing data from
* @param len The number of bytes to write from the buffer to the output stream * @param len The number of bytes to write from the buffer to the output
* stream
* *
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
*/ */
void void write(byte[] buf, int offset, int len) throws IOException;
write(byte[] buf, int offset, int len) throws IOException;
} // interface DataOutput } // interface DataOutput
...@@ -56,19 +56,19 @@ package java.io; ...@@ -56,19 +56,19 @@ package java.io;
* created using the default no-argument constructor and the * created using the default no-argument constructor and the
* <code>readExternal</code> method is used to restore the state. * <code>readExternal</code> method is used to restore the state.
* *
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
*/ */
public interface Externalizable extends Serializable public interface Externalizable extends Serializable
{ {
static final long serialVersionUID = -282491828744381764L; static final long serialVersionUID = -282491828744381764L;
/** /**
* This method restores an object's state by reading in the instance data * This method restores an object's state by reading in the instance data
* for the object from the passed in stream. Note that this stream is not * for the object from the passed in stream. Note that this stream is not
* a subclass of <code>InputStream</code>, but rather is a class that implements * a subclass of <code>InputStream</code>, but rather is a class that
* the <code>ObjectInput</code> interface. That interface provides a mechanism for * implements
* the <code>ObjectInput</code> interface. That interface provides a
* mechanism for
* reading in Java data types from a stream. * reading in Java data types from a stream.
* <p> * <p>
* Note that this method must be compatible with <code>writeExternal</code>. * Note that this method must be compatible with <code>writeExternal</code>.
...@@ -79,32 +79,35 @@ public interface Externalizable extends Serializable ...@@ -79,32 +79,35 @@ public interface Externalizable extends Serializable
* for that object must be found and loaded. If that operation fails, * for that object must be found and loaded. If that operation fails,
* then this method throws a <code>ClassNotFoundException</code> * then this method throws a <code>ClassNotFoundException</code>
* *
* @param in An <code>ObjectInput</code> instance for reading in the object state * @param in An <code>ObjectInput</code> instance for reading in the object
* state
* *
* @exception ClassNotFoundException If the class of an object being restored cannot be found * @exception ClassNotFoundException If the class of an object being
* restored cannot be found
* @exception IOException If any other error occurs * @exception IOException If any other error occurs
*/ */
public abstract void public abstract void readExternal(ObjectInput in)
readExternal(ObjectInput in) throws ClassNotFoundException, IOException; throws ClassNotFoundException, IOException;
/*************************************************************************/ /*************************************************************************/
/** /**
* This method is responsible for writing the instance data of an object * This method is responsible for writing the instance data of an object
* to the passed in stream. Note that this stream is not a subclass of * to the passed in stream. Note that this stream is not a subclass of
* <code>OutputStream</code>, but rather is a class that implements the * <code>OutputStream</code>, but rather is a class that implements the
* <code>ObjectOutput</code> interface. That interface provides a number of methods * <code>ObjectOutput</code> interface. That interface provides a
* number of methods
* for writing Java data values to a stream. * for writing Java data values to a stream.
* <p> * <p>
* Not that the implementation of this method must be coordinated with * Not that the implementation of this method must be coordinated with
* the implementation of <code>readExternal</code>. * the implementation of <code>readExternal</code>.
* *
* @param out An <code>ObjectOutput</code> instance for writing the object state * @param out An <code>ObjectOutput</code> instance for writing the
* object state
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public abstract void public abstract void writeExternal(ObjectOutput out) throws IOException;
writeExternal(ObjectOutput out) throws IOException;
} // interface Externalizable } // interface Externalizable
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment