From 83f564f76ff896424c3ac8d6cde45867e9c083c0 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Tue, 6 May 2003 10:07:28 +0000 Subject: 2003-05-06 Michael Koch * java/io/DataOutputStream.java (write): Renamed argument to "value", merged documentation from classpath. (writeBoolean): Likewise. (writeByte): Likewise. (writeShort): Likewise. (writeChar): Likewise. (writeInt): Likewise. (writeLong): Likewise. (writeFloat): Likewise. (writeDouble): Likewise. (writeBytes): Likewise. (writeChars): Likewise. (writeUTF): Likewise. * java/io/File.java (performDelete): Added documentation. (performList): Likewise. (performMkdir): Likewise. (performSetReadOnly): Likewise. (performRenameTo): Likewise. (performSetLastModified): Likewise. (delete): Made it sychronized. (renameTo): Made it sychronized. (equals): Reformatted. (isHidden): Likewise. (listFiles): Likewise. (setReadOnly): Likewise. (listRoots): Likewise. (setLastModified): Likewise. (checkRead): Likewise. (checkWrite): Likewise. * java/io/FileInputStream.java (skip): Made it sychronized, merged from classpath. * java/io/FileOutputStream.java (write): Merged from classpath. * java/io/InputStreamReader.java: (InputStreamReader): Merged documentation from classpath. From-SVN: r66520 --- libjava/java/io/DataOutputStream.java | 216 +++++++++++++++++++++++----------- 1 file changed, 149 insertions(+), 67 deletions(-) (limited to 'libjava/java/io/DataOutputStream.java') diff --git a/libjava/java/io/DataOutputStream.java b/libjava/java/io/DataOutputStream.java index 644b5901c33..d5f76ff8124 100644 --- a/libjava/java/io/DataOutputStream.java +++ b/libjava/java/io/DataOutputStream.java @@ -101,13 +101,13 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput * This method writes the specified byte (passed as an int) * to the underlying output stream. * - * @param b The byte to write, passed as an int. + * @param value The byte to write, passed as an int. * * @exception IOException If an error occurs. */ - public synchronized void write (int b) throws IOException + public synchronized void write (int value) throws IOException { - out.write(b); + out.write (value); ++written; } @@ -130,116 +130,185 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput } /** - * This method writes a Java boolean to the underlying output - * stream. For a value of true, 1 is written to the stream. - * For a value of false, 0 is written. + * This method writes a Java boolean value to an output stream. If + * value is true, a byte with the value of + * 1 will be written, otherwise a byte with the value of 0 will be + * written. * - * @param b The boolean value to write to the stream + * The value written can be read using the readBoolean + * method in DataInput. + * + * @param value The boolean value to write to the stream * * @exception IOException If an error occurs + * + * @see DataInput#readBoolean */ - public final void writeBoolean (boolean v) throws IOException + public final void writeBoolean (boolean value) throws IOException { - write (v ? 1 : 0); + write (value ? 1 : 0); } /** - * This method writes a Java byte value to the underlying - * output stream. + * This method writes a Java byte value to an output stream. The + * byte to be written will be in the lowest 8 bits of the + * int value passed. + * + * The value written can be read using the readByte or + * readUnsignedByte methods in DataInput. * - * @param b The byte to write to the stream, passed as + * @param value The byte to write to the stream, passed as * the low eight bits of an int. * * @exception IOException If an error occurs + * + * @see DataInput#readByte + * @see DataInput#readUnsignedByte */ - public final void writeByte (int v) throws IOException + public final void writeByte (int value) throws IOException { - write (v & 0xff); + write (value & 0xff); } /** - * This method writes a Java short to the stream, high byte - * first. This method requires two bytes to encode the value. + * This method writes a Java short value to an output stream. The + * char to be written will be in the lowest 16 bits of the int + * value passed. These bytes will be written "big endian". That is, + * with the high byte written first in the following manner: + *

+ * byte0 = (byte)((value & 0xFF00) >> 8);
+ * byte1 = (byte)(value & 0x00FF);
+ *

+ * + * The value written can be read using the readShort and + * readUnsignedShort methods in DataInput. * - * @param s The short value to write to the stream, + * @param value The short value to write to the stream, * passed as an int. * * @exception IOException If an error occurs + * + * @see DataInput#readShort + * @see DataInput#readUnsignedShort */ - public final void writeShort (int v) throws IOException + public final void writeShort (int value) throws IOException { - write ((byte) (0xff & (v >> 8))); - write ((byte) (0xff & v)); + write ((byte) (0xff & (value >> 8))); + write ((byte) (0xff & value)); } /** - * This method writes a single char value to the stream, - * high byte first. + * This method writes a Java char value to an output stream. The + * char to be written will be in the lowest 16 bits of the int + * value passed. These bytes will be written "big endian". That is, + * with the high byte written first in the following manner: + *

+ * byte0 = (byte)((value & 0xFF00) >> 8);
+ * byte1 = (byte)(value & 0x00FF);
+ *

+ * + * The value written can be read using the readChar + * method in DataInput. * - * @param c The char value to write, + * @param value The char value to write, * passed as an int. * * @exception IOException If an error occurs + * + * @see DataInput#readChar */ - public final void writeChar (int v) throws IOException + public final void writeChar (int value) throws IOException { - write ((byte) (0xff & (v >> 8))); - write ((byte) (0xff & v)); + write ((byte) (0xff & (value >> 8))); + write ((byte) (0xff & value)); } /** - * This method writes a Java int to the stream, high bytes - * first. This method requires four bytes to encode the value. + * This method writes a Java int value to an output stream. The 4 bytes + * of the passed value will be written "big endian". That is, with + * the high byte written first in the following manner: + *

+ * byte0 = (byte)((value & 0xFF000000) >> 24);
+ * byte1 = (byte)((value & 0x00FF0000) >> 16);
+ * byte2 = (byte)((value & 0x0000FF00) >> 8);
+ * byte3 = (byte)(value & 0x000000FF);
+ *

* - * @param i The int value to write to the stream. + * The value written can be read using the readInt + * method in DataInput. + * + * @param value The int value to write to the stream * * @exception IOException If an error occurs + * + * @see DataInput#readInt */ - public final void writeInt (int v) throws IOException + public final void writeInt (int value) throws IOException { - write ((byte) (0xff & (v >> 24))); - write ((byte) (0xff & (v >> 16))); - write ((byte) (0xff & (v >> 8))); - write ((byte) (0xff & v)); + write ((byte) (0xff & (value >> 24))); + write ((byte) (0xff & (value >> 16))); + write ((byte) (0xff & (value >> 8))); + write ((byte) (0xff & value)); } /** - * This method writes a Java long to the stream, high bytes - * first. This method requires eight bytes to encode the value. + * This method writes a Java long value to an output stream. The 8 bytes + * of the passed value will be written "big endian". That is, with + * the high byte written first in the following manner: + *

+ * byte0 = (byte)((value & 0xFF00000000000000L) >> 56);
+ * byte1 = (byte)((value & 0x00FF000000000000L) >> 48);
+ * byte2 = (byte)((value & 0x0000FF0000000000L) >> 40);
+ * byte3 = (byte)((value & 0x000000FF00000000L) >> 32);
+ * byte4 = (byte)((value & 0x00000000FF000000L) >> 24);
+ * byte5 = (byte)((value & 0x0000000000FF0000L) >> 16);
+ * byte6 = (byte)((value & 0x000000000000FF00L) >> 8);
+ * byte7 = (byte)(value & 0x00000000000000FFL);
+ *

* - * @param l The long value to write to the stream. + * The value written can be read using the readLong + * method in DataInput. + * + * @param value The long value to write to the stream * * @exception IOException If an error occurs + * + * @see DataInput#readLong */ - public final void writeLong (long v) throws IOException + public final void writeLong (long value) throws IOException { - write ((byte) (0xff & (v >> 56))); - write ((byte) (0xff & (v >> 48))); - write ((byte) (0xff & (v >> 40))); - write ((byte) (0xff & (v >> 32))); - write ((byte) (0xff & (v >> 24))); - write ((byte) (0xff & (v >> 16))); - write ((byte) (0xff & (v >> 8))); - write ((byte) (0xff & v)); + write ((byte) (0xff & (value >> 56))); + write ((byte) (0xff & (value>> 48))); + write ((byte) (0xff & (value>> 40))); + write ((byte) (0xff & (value>> 32))); + write ((byte) (0xff & (value>> 24))); + write ((byte) (0xff & (value>> 16))); + write ((byte) (0xff & (value>> 8))); + write ((byte) (0xff & value)); } /** * This method writes a Java float value to the stream. This - * value is written by first calling the method + * value is written by first calling the method * Float.floatToIntBits * to retrieve an int representing the floating point number, * then writing this int value to the stream exactly the same * as the writeInt() method does. * - * @param f The floating point number to write to the stream. + * The value written can be read using the readFloat + * method in DataInput. + * + * @param value The float value to write to the stream * * @exception IOException If an error occurs * * @see writeInt + * @see DataInput#readFloat + * @see Float#floatToIntBits */ - public final void writeFloat (float v) throws IOException + public final void writeFloat (float value) throws IOException { - writeInt (Float.floatToIntBits(v)); + writeInt (Float.floatToIntBits (value)); } /** @@ -250,49 +319,57 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput * then writing this long value to the stream exactly the same * as the writeLong() method does. * - * @param d The double precision floating point number to write to - * the stream. + * The value written can be read using the readDouble + * method in DataInput. + * + * @param value The double value to write to the stream * * @exception IOException If an error occurs * * @see writeLong + * @see DataInput#readDouble + * @see Double#doubleToLongBits */ - public final void writeDouble (double v) throws IOException + public final void writeDouble (double value) throws IOException { - writeLong (Double.doubleToLongBits(v)); + writeLong (Double.doubleToLongBits (value)); } /** * This method writes all the bytes in a String out to the * stream. One byte is written for each character in the * String. - * The high eight bits of each character are discarded. + * The high eight bits of each character are discarded, thus this + * method is inappropriate for completely representing Unicode characters. * - * @param s The String to write to the stream + * @param value The String to write to the stream * * @exception IOException If an error occurs */ - public final void writeBytes (String s) throws IOException + public final void writeBytes (String value) throws IOException { - int len = s.length(); + int len = value.length(); for (int i = 0; i < len; ++i) - writeByte (s.charAt(i)); + writeByte (value.charAt(i)); } /** - * This method writes all the characters in a String to the - * stream. There will be two bytes for each character value. The high - * byte of the character will be written first. + * This method writes all the characters of a String to an + * output stream as an array of char's. Each character + * is written using the method specified in the writeChar + * method. * - * @param s The String to write to the stream. + * @param value The String to write to the stream * * @exception IOException If an error occurs + * + * @see writeChar */ - public final void writeChars (String s) throws IOException + public final void writeChars (String value) throws IOException { - int len = s.length(); + int len = value.length(); for (int i = 0; i < len; ++i) - writeChar (s.charAt(i)); + writeChar (value.charAt(i)); } /** @@ -318,9 +395,14 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput * character value are stored in bits 0-5 of byte three, with the high bits * of that byte set to "10". * - * @param s The String to write to the output in UTF format + * The value written can be read using the readUTF + * method in DataInput. + * + * @param value The String to write to the output in UTF format * * @exception IOException If an error occurs + * + * @see DataInput#readUTF */ public final void writeUTF (String s) throws IOException { -- cgit v1.2.3