2003-05-09 Michael Koch <konqueror@gmx.de>
* java/io/DataOutputStream.java (writeShort): Made it synchronized. (writeChar): Likewise. (writeInt): Likewise. (writeLong): Liekwise. (writeUTF): Made it synchronized, renamed argument to match classpath. * java/io/InputStreamReader.java (converter): Added documentation. (read): Merged documentation from classpath. * java/io/OutputStreamWriter.java (OutputStreamWriter): Merged documentation from classpath. (close): Reformatted. (getEncoding): Likewise. (flush): Likewise. (write): Merged documentation from classpath, reformatted. From-SVN: r66624
This commit is contained in:
parent
c6b97fac18
commit
d8048dc2f7
|
@ -1,3 +1,21 @@
|
||||||
|
2003-05-09 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
|
* java/io/DataOutputStream.java
|
||||||
|
(writeShort): Made it synchronized.
|
||||||
|
(writeChar): Likewise.
|
||||||
|
(writeInt): Likewise.
|
||||||
|
(writeLong): Liekwise.
|
||||||
|
(writeUTF): Made it synchronized, renamed argument to match classpath.
|
||||||
|
* java/io/InputStreamReader.java
|
||||||
|
(converter): Added documentation.
|
||||||
|
(read): Merged documentation from classpath.
|
||||||
|
* java/io/OutputStreamWriter.java
|
||||||
|
(OutputStreamWriter): Merged documentation from classpath.
|
||||||
|
(close): Reformatted.
|
||||||
|
(getEncoding): Likewise.
|
||||||
|
(flush): Likewise.
|
||||||
|
(write): Merged documentation from classpath, reformatted.
|
||||||
|
|
||||||
2003-05-08 Tom Tromey <tromey@redhat.com>
|
2003-05-08 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* configure.host <powerpc64*-*>: Set with_libffi_default and
|
* configure.host <powerpc64*-*>: Set with_libffi_default and
|
||||||
|
|
|
@ -191,7 +191,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
||||||
* @see DataInput#readShort
|
* @see DataInput#readShort
|
||||||
* @see DataInput#readUnsignedShort
|
* @see DataInput#readUnsignedShort
|
||||||
*/
|
*/
|
||||||
public final void writeShort (int value) throws IOException
|
public final synchronized void writeShort (int value) throws IOException
|
||||||
{
|
{
|
||||||
write ((byte) (0xff & (value >> 8)));
|
write ((byte) (0xff & (value >> 8)));
|
||||||
write ((byte) (0xff & value));
|
write ((byte) (0xff & value));
|
||||||
|
@ -217,7 +217,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
||||||
*
|
*
|
||||||
* @see DataInput#readChar
|
* @see DataInput#readChar
|
||||||
*/
|
*/
|
||||||
public final void writeChar (int value) throws IOException
|
public final synchronized void writeChar (int value) throws IOException
|
||||||
{
|
{
|
||||||
write ((byte) (0xff & (value >> 8)));
|
write ((byte) (0xff & (value >> 8)));
|
||||||
write ((byte) (0xff & value));
|
write ((byte) (0xff & value));
|
||||||
|
@ -243,7 +243,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
||||||
*
|
*
|
||||||
* @see DataInput#readInt
|
* @see DataInput#readInt
|
||||||
*/
|
*/
|
||||||
public final void writeInt (int value) throws IOException
|
public final synchronized void writeInt (int value) throws IOException
|
||||||
{
|
{
|
||||||
write ((byte) (0xff & (value >> 24)));
|
write ((byte) (0xff & (value >> 24)));
|
||||||
write ((byte) (0xff & (value >> 16)));
|
write ((byte) (0xff & (value >> 16)));
|
||||||
|
@ -275,7 +275,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
||||||
*
|
*
|
||||||
* @see DataInput#readLong
|
* @see DataInput#readLong
|
||||||
*/
|
*/
|
||||||
public final void writeLong (long value) throws IOException
|
public final synchronized void writeLong (long value) throws IOException
|
||||||
{
|
{
|
||||||
write ((byte) (0xff & (value >> 56)));
|
write ((byte) (0xff & (value >> 56)));
|
||||||
write ((byte) (0xff & (value>> 48)));
|
write ((byte) (0xff & (value>> 48)));
|
||||||
|
@ -404,14 +404,14 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
||||||
*
|
*
|
||||||
* @see DataInput#readUTF
|
* @see DataInput#readUTF
|
||||||
*/
|
*/
|
||||||
public final void writeUTF (String s) throws IOException
|
public synchronized final void writeUTF (String value) throws IOException
|
||||||
{
|
{
|
||||||
int len = s.length();
|
int len = value.length();
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
|
||||||
for (int i = 0; i < len && sum <= 65535; ++i)
|
for (int i = 0; i < len && sum <= 65535; ++i)
|
||||||
{
|
{
|
||||||
char c = s.charAt(i);
|
char c = value.charAt(i);
|
||||||
if (c >= '\u0001' && c <= '\u007f')
|
if (c >= '\u0001' && c <= '\u007f')
|
||||||
sum += 1;
|
sum += 1;
|
||||||
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
|
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
|
||||||
|
@ -427,7 +427,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
||||||
|
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
char c = s.charAt(i);
|
char c = value.charAt(i);
|
||||||
if (c >= '\u0001' && c <= '\u007f')
|
if (c >= '\u0001' && c <= '\u007f')
|
||||||
write (c);
|
write (c);
|
||||||
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
|
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
|
||||||
|
|
|
@ -96,6 +96,10 @@ public class InputStreamReader extends Reader
|
||||||
// Last available character (in work buffer) to read.
|
// Last available character (in work buffer) to read.
|
||||||
int wcount;
|
int wcount;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the byte-character decoder class that does the reading and
|
||||||
|
* translation of bytes from the underlying stream.
|
||||||
|
*/
|
||||||
BytesToUnicode converter;
|
BytesToUnicode converter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +205,20 @@ public class InputStreamReader extends Reader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read(char buf[], int offset, int length) throws IOException
|
/**
|
||||||
|
* This method reads up to <code>length</code> characters from the stream into
|
||||||
|
* the specified array starting at index <code>offset</code> into the
|
||||||
|
* array.
|
||||||
|
*
|
||||||
|
* @param buf The character array to recieve the data read
|
||||||
|
* @param offset The offset into the array to start storing characters
|
||||||
|
* @param length The requested number of characters to read.
|
||||||
|
*
|
||||||
|
* @return The actual number of characters read, or -1 if end of stream.
|
||||||
|
*
|
||||||
|
* @exception IOException If an error occurs
|
||||||
|
*/
|
||||||
|
public int read (char[] buf, int offset, int length) throws IOException
|
||||||
{
|
{
|
||||||
synchronized (lock)
|
synchronized (lock)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,20 +37,51 @@ exception statement from your version. */
|
||||||
|
|
||||||
|
|
||||||
package java.io;
|
package java.io;
|
||||||
|
|
||||||
import gnu.gcj.convert.UnicodeToBytes;
|
import gnu.gcj.convert.UnicodeToBytes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This class writes characters to an output stream that is byte oriented
|
||||||
|
* It converts the chars that are written to bytes using an encoding layer,
|
||||||
|
* which is specific to a particular encoding standard. The desired
|
||||||
|
* encoding can either be specified by name, or if no encoding is specified,
|
||||||
|
* the system default encoding will be used. The system default encoding
|
||||||
|
* name is determined from the system property <code>file.encoding</code>.
|
||||||
|
* The only encodings that are guaranteed to be available are "8859_1"
|
||||||
|
* (the Latin-1 character set) and "UTF8". Unfortunately, Java does not
|
||||||
|
* provide a mechanism for listing the encodings that are supported in
|
||||||
|
* a given implementation.
|
||||||
|
* <p>
|
||||||
|
* Here is a list of standard encoding names that may be available:
|
||||||
|
* <p>
|
||||||
|
* <ul>
|
||||||
|
* <li>8859_1 (ISO-8859-1/Latin-1)
|
||||||
|
* <li>8859_2 (ISO-8859-2/Latin-2)
|
||||||
|
* <li>8859_3 (ISO-8859-3/Latin-3)
|
||||||
|
* <li>8859_4 (ISO-8859-4/Latin-4)
|
||||||
|
* <li>8859_5 (ISO-8859-5/Latin-5)
|
||||||
|
* <li>8859_6 (ISO-8859-6/Latin-6)
|
||||||
|
* <li>8859_7 (ISO-8859-7/Latin-7)
|
||||||
|
* <li>8859_8 (ISO-8859-8/Latin-8)
|
||||||
|
* <li>8859_9 (ISO-8859-9/Latin-9)
|
||||||
|
* <li>ASCII (7-bit ASCII)
|
||||||
|
* <li>UTF8 (UCS Transformation Format-8)
|
||||||
|
* <li>More Later
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||||
* @author Per Bothner <bothner@cygnus.com>
|
* @author Per Bothner <bothner@cygnus.com>
|
||||||
* @date April 17, 1998.
|
* @date April 17, 1998.
|
||||||
*/
|
*/
|
||||||
/* Written using "Java Class Libraries", 2nd edition, plus online
|
|
||||||
* API docs for JDK 1.2 beta from http://www.javasoft.com.
|
|
||||||
* Status: Believed complete and correct, but only supports 8859_1.
|
|
||||||
*/
|
|
||||||
public class OutputStreamWriter extends Writer
|
public class OutputStreamWriter extends Writer
|
||||||
{
|
{
|
||||||
BufferedOutputStream out;
|
BufferedOutputStream out;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the byte-character encoder class that does the writing and
|
||||||
|
* translation of characters to bytes before writing to the underlying
|
||||||
|
* class.
|
||||||
|
*/
|
||||||
UnicodeToBytes converter;
|
UnicodeToBytes converter;
|
||||||
|
|
||||||
/* Temporary buffer. */
|
/* Temporary buffer. */
|
||||||
|
@ -67,8 +98,21 @@ public class OutputStreamWriter extends Writer
|
||||||
this.converter = encoder;
|
this.converter = encoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutputStreamWriter(OutputStream out, String encoding_scheme)
|
/**
|
||||||
throws UnsupportedEncodingException
|
* This method initializes a new instance of <code>OutputStreamWriter</code>
|
||||||
|
* to write to the specified stream using a caller supplied character
|
||||||
|
* encoding scheme. Note that due to a deficiency in the Java language
|
||||||
|
* design, there is no way to determine which encodings are supported.
|
||||||
|
*
|
||||||
|
* @param out The <code>OutputStream</code> to write to
|
||||||
|
* @param encoding_scheme The name of the encoding scheme to use for
|
||||||
|
* character to byte translation
|
||||||
|
*
|
||||||
|
* @exception UnsupportedEncodingException If the named encoding is
|
||||||
|
* not available.
|
||||||
|
*/
|
||||||
|
public OutputStreamWriter (OutputStream out, String encoding_scheme)
|
||||||
|
throws UnsupportedEncodingException
|
||||||
{
|
{
|
||||||
this(out, UnicodeToBytes.getEncoder(encoding_scheme));
|
this(out, UnicodeToBytes.getEncoder(encoding_scheme));
|
||||||
}
|
}
|
||||||
|
@ -79,7 +123,7 @@ public class OutputStreamWriter extends Writer
|
||||||
*
|
*
|
||||||
* @param out The <code>OutputStream</code> to write to
|
* @param out The <code>OutputStream</code> to write to
|
||||||
*/
|
*/
|
||||||
public OutputStreamWriter(OutputStream out)
|
public OutputStreamWriter (OutputStream out)
|
||||||
{
|
{
|
||||||
this(out, UnicodeToBytes.getDefaultEncoder());
|
this(out, UnicodeToBytes.getDefaultEncoder());
|
||||||
}
|
}
|
||||||
|
@ -90,7 +134,7 @@ public class OutputStreamWriter extends Writer
|
||||||
*
|
*
|
||||||
* @exception IOException If an error occurs
|
* @exception IOException If an error occurs
|
||||||
*/
|
*/
|
||||||
public void close() throws IOException
|
public void close () throws IOException
|
||||||
{
|
{
|
||||||
synchronized (lock)
|
synchronized (lock)
|
||||||
{
|
{
|
||||||
|
@ -111,7 +155,7 @@ public class OutputStreamWriter extends Writer
|
||||||
*
|
*
|
||||||
* @return The encoding scheme name
|
* @return The encoding scheme name
|
||||||
*/
|
*/
|
||||||
public String getEncoding()
|
public String getEncoding ()
|
||||||
{
|
{
|
||||||
return out != null ? converter.getName() : null;
|
return out != null ? converter.getName() : null;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +165,7 @@ public class OutputStreamWriter extends Writer
|
||||||
*
|
*
|
||||||
* @exception IOException If an error occurs
|
* @exception IOException If an error occurs
|
||||||
*/
|
*/
|
||||||
public void flush() throws IOException
|
public void flush () throws IOException
|
||||||
{
|
{
|
||||||
synchronized (lock)
|
synchronized (lock)
|
||||||
{
|
{
|
||||||
|
@ -137,8 +181,18 @@ public class OutputStreamWriter extends Writer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(char[] buf, int offset, int count)
|
/**
|
||||||
throws IOException
|
* This method writes <code>count</code> characters from the specified
|
||||||
|
* array to the output stream starting at position <code>offset</code>
|
||||||
|
* into the array.
|
||||||
|
*
|
||||||
|
* @param buf The array of character to write from
|
||||||
|
* @param offset The offset into the array to start writing chars from
|
||||||
|
* @param count The number of chars to write.
|
||||||
|
*
|
||||||
|
* @exception IOException If an error occurs
|
||||||
|
*/
|
||||||
|
public void write (char[] buf, int offset, int count) throws IOException
|
||||||
{
|
{
|
||||||
synchronized (lock)
|
synchronized (lock)
|
||||||
{
|
{
|
||||||
|
@ -154,8 +208,10 @@ public class OutputStreamWriter extends Writer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes characters through to the inferior BufferedOutputStream.
|
/*
|
||||||
* Ignores wcount and the work buffer. */
|
* Writes characters through to the inferior BufferedOutputStream.
|
||||||
|
* Ignores wcount and the work buffer.
|
||||||
|
*/
|
||||||
private void writeChars(char[] buf, int offset, int count)
|
private void writeChars(char[] buf, int offset, int count)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
@ -178,8 +234,19 @@ public class OutputStreamWriter extends Writer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(String str, int offset, int count)
|
/**
|
||||||
throws IOException
|
* This method writes <code>count</code> bytes from the specified
|
||||||
|
* <code>String</code> starting at position <code>offset</code> into the
|
||||||
|
* <code>String</code>.
|
||||||
|
*
|
||||||
|
* @param str The <code>String</code> to write chars from
|
||||||
|
* @param offset The position in the <code>String</code> to start
|
||||||
|
* writing chars from
|
||||||
|
* @param count The number of chars to write
|
||||||
|
*
|
||||||
|
* @exception IOException If an error occurs
|
||||||
|
*/
|
||||||
|
public void write (String str, int offset, int count) throws IOException
|
||||||
{
|
{
|
||||||
synchronized (lock)
|
synchronized (lock)
|
||||||
{
|
{
|
||||||
|
@ -217,7 +284,7 @@ public class OutputStreamWriter extends Writer
|
||||||
*
|
*
|
||||||
* @exception IOException If an error occurs
|
* @exception IOException If an error occurs
|
||||||
*/
|
*/
|
||||||
public void write(int ch) throws IOException
|
public void write (int ch) throws IOException
|
||||||
{
|
{
|
||||||
synchronized (lock)
|
synchronized (lock)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue