diff options
author | Michael Koch <konqueror@gmx.de> | 2003-03-24 15:43:22 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2003-03-24 15:43:22 +0000 |
commit | 950ebbeaf050929030c0bb0b89c9d0aa870d973d (patch) | |
tree | 750d1ed56fc294b0379fe7e0121d2ea862ae4dde /libjava/java/io | |
parent | 6db450f90a63561e279076b6b143c035369265af (diff) | |
download | gcc-950ebbeaf050929030c0bb0b89c9d0aa870d973d.zip gcc-950ebbeaf050929030c0bb0b89c9d0aa870d973d.tar.gz gcc-950ebbeaf050929030c0bb0b89c9d0aa870d973d.tar.bz2 |
2003-03-24 Michael Koch <konqueror@gmx.de>
* java/io/DataOutputStream.java
(write): Merged from classpath.
* java/io/File.java:
Merged copyrigth with classpath.
* java/io/FileInputStream.java
(getChannel): Made it synchronized instead of using a synchronized
block.
* java/io/FileOutputStream.java: Reformatted.
* java/io/InputStreamReader.java
(InputStreamReader): Renamed enc to encoding_name.
(close): Merged documentation from classpath.
(getEncoding): Merged documentation from classpath.
(ready): Merged documentation from classpath.
(read): Merged documentation from classpath.
* java/io/LineNumberReader.java
(lineNumber): Made it private.
(LineNumberReader): Use Constant instead of a direct value.
* java/io/OutputStreamWriter.java
(OutputStreamWriter): Renamed enc to encoding_scheme, merged
documentation from classpath.
(close): Merged documentation from classpath.
(flush): Merged documentation from classpath.
(write): Merged documentation from classpath.
* java/io/PrintStream.java: Reformatted.
From-SVN: r64806
Diffstat (limited to 'libjava/java/io')
-rw-r--r-- | libjava/java/io/DataOutputStream.java | 6 | ||||
-rw-r--r-- | libjava/java/io/File.java | 2 | ||||
-rw-r--r-- | libjava/java/io/FileInputStream.java | 11 | ||||
-rw-r--r-- | libjava/java/io/FileOutputStream.java | 16 | ||||
-rw-r--r-- | libjava/java/io/InputStreamReader.java | 39 | ||||
-rw-r--r-- | libjava/java/io/LineNumberReader.java | 4 | ||||
-rw-r--r-- | libjava/java/io/OutputStreamWriter.java | 49 | ||||
-rw-r--r-- | libjava/java/io/PrintStream.java | 36 |
8 files changed, 113 insertions, 50 deletions
diff --git a/libjava/java/io/DataOutputStream.java b/libjava/java/io/DataOutputStream.java index 8fe9bbe..644b590 100644 --- a/libjava/java/io/DataOutputStream.java +++ b/libjava/java/io/DataOutputStream.java @@ -122,10 +122,10 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput * * @exception IOException If an error occurs. */ - public synchronized void write (byte[] b, int off, int len) - throws IOException, NullPointerException, IndexOutOfBoundsException + public synchronized void write (byte[] buf, int offset, int len) + throws IOException { - out.write(b, off, len); + out.write(buf, offset, len); written += len; } diff --git a/libjava/java/io/File.java b/libjava/java/io/File.java index e0aaaf9..eb457b3 100644 --- a/libjava/java/io/File.java +++ b/libjava/java/io/File.java @@ -1,5 +1,5 @@ /* File.java -- Class representing a file on disk - Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/libjava/java/io/FileInputStream.java b/libjava/java/io/FileInputStream.java index 63390ec..533dd08 100644 --- a/libjava/java/io/FileInputStream.java +++ b/libjava/java/io/FileInputStream.java @@ -280,15 +280,12 @@ public class FileInputStream extends InputStream * A file channel must be created by first creating an instance of * Input/Output/RandomAccessFile and invoking the getChannel() method on it. */ - public FileChannel getChannel () + public synchronized FileChannel getChannel () { - synchronized (this) - { - if (ch == null) - ch = new FileChannelImpl (fd, false, this); + if (ch == null) + ch = new FileChannelImpl (fd, false, this); - return ch; - } + return ch; } } // class FileInputStream diff --git a/libjava/java/io/FileOutputStream.java b/libjava/java/io/FileOutputStream.java index e8a4f08..ac82361 100644 --- a/libjava/java/io/FileOutputStream.java +++ b/libjava/java/io/FileOutputStream.java @@ -41,18 +41,21 @@ package java.io; import java.nio.channels.FileChannel; import gnu.java.nio.FileChannelImpl; -/** - * @author Tom Tromey <tromey@cygnus.com> - * @date September 24, 1998 - */ - /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 * "The Java Language Specification", ISBN 0-201-63451-1 * Status: Complete to version 1.1. */ +/** + * @author Tom Tromey <tromey@cygnus.com> + * @date September 24, 1998 + */ public class FileOutputStream extends OutputStream { + // Instance variables. + private FileDescriptor fd; + private FileChannel ch; + public FileOutputStream (String path, boolean append) throws SecurityException, FileNotFoundException { @@ -159,7 +162,4 @@ public class FileOutputStream extends OutputStream } } - // Instance variables. - private FileDescriptor fd; - private FileChannel ch; } diff --git a/libjava/java/io/InputStreamReader.java b/libjava/java/io/InputStreamReader.java index 51ddf76..70213b5 100644 --- a/libjava/java/io/InputStreamReader.java +++ b/libjava/java/io/InputStreamReader.java @@ -66,10 +66,10 @@ public class InputStreamReader extends Reader this(in, BytesToUnicode.getDefaultDecoder()); } - public InputStreamReader(InputStream in, String enc) + public InputStreamReader(InputStream in, String encoding_name) throws UnsupportedEncodingException { - this(in, BytesToUnicode.getDecoder(enc)); + this(in, BytesToUnicode.getDecoder(encoding_name)); } private InputStreamReader(InputStream in, BytesToUnicode decoder) @@ -88,6 +88,12 @@ public class InputStreamReader extends Reader converter.setInput(this.in.buf, 0, 0); } + /** + * This method closes this stream, as well as the underlying + * <code>InputStream</code>. + * + * @exception IOException If an error occurs + */ public void close() throws IOException { synchronized (lock) @@ -100,11 +106,29 @@ public class InputStreamReader extends Reader } } + /** + * This method returns the name of the encoding that is currently in use + * by this object. If the stream has been closed, this method is allowed + * to return <code>null</code>. + * + * @param The current encoding name + */ public String getEncoding() { return in != null ? converter.getName() : null; } + /** + * This method checks to see if the stream is read to be read. It + * will return <code>true</code> if is, or <code>false</code> if it is not. + * If the stream is not ready to be read, it could (although is not required + * to) block on the next read attempt. + * + * @return <code>true</code> if the stream is ready to be read, + * <code>false</code> otherwise + * + * @exception IOException If an error occurs + */ public boolean ready() throws IOException { synchronized (lock) @@ -149,6 +173,13 @@ public class InputStreamReader extends Reader } } + /** + * This method reads a single character of data from the stream. + * + * @return The char read, as an int, or -1 if end of stream. + * + * @exception IOException If an error occurs + */ public int read() throws IOException { synchronized (lock) @@ -198,4 +229,6 @@ public class InputStreamReader extends Reader } } } -} + +} // class InputStreamReader + diff --git a/libjava/java/io/LineNumberReader.java b/libjava/java/io/LineNumberReader.java index 73b3b90..9d80745 100644 --- a/libjava/java/io/LineNumberReader.java +++ b/libjava/java/io/LineNumberReader.java @@ -70,7 +70,7 @@ package java.io; public class LineNumberReader extends BufferedReader { /** The current line number. */ - int lineNumber; + private int lineNumber; /** * Create a new <code>LineNumberReader</code> that reads from the @@ -81,7 +81,7 @@ public class LineNumberReader extends BufferedReader */ public LineNumberReader(Reader in) { - super(in, 8192); + super(in, DEFAULT_BUFFER_SIZE); } /** diff --git a/libjava/java/io/OutputStreamWriter.java b/libjava/java/io/OutputStreamWriter.java index a284542..1d63d56 100644 --- a/libjava/java/io/OutputStreamWriter.java +++ b/libjava/java/io/OutputStreamWriter.java @@ -57,11 +57,6 @@ public class OutputStreamWriter extends Writer private char[] work; private int wcount; - public String getEncoding() - { - return out != null ? converter.getName() : null; - } - private OutputStreamWriter(OutputStream out, UnicodeToBytes encoder) { this.out = out instanceof BufferedOutputStream @@ -72,17 +67,29 @@ public class OutputStreamWriter extends Writer this.converter = encoder; } - public OutputStreamWriter(OutputStream out, String enc) + public OutputStreamWriter(OutputStream out, String encoding_scheme) throws UnsupportedEncodingException { - this(out, UnicodeToBytes.getEncoder(enc)); + this(out, UnicodeToBytes.getEncoder(encoding_scheme)); } + /** + * This method initializes a new instance of <code>OutputStreamWriter</code> + * to write to the specified stream using the default encoding. + * + * @param out The <code>OutputStream</code> to write to + */ public OutputStreamWriter(OutputStream out) { this(out, UnicodeToBytes.getDefaultEncoder()); } + /** + * This method closes this stream, and the underlying + * <code>OutputStream</code> + * + * @exception IOException If an error occurs + */ public void close() throws IOException { synchronized (lock) @@ -97,6 +104,23 @@ public class OutputStreamWriter extends Writer } } + /** + * This method returns the name of the character encoding scheme currently + * in use by this stream. If the stream has been closed, then this method + * may return <code>null</code>. + * + * @return The encoding scheme name + */ + public String getEncoding() + { + return out != null ? converter.getName() : null; + } + + /** + * This method flushes any buffered bytes to the underlying output sink. + * + * @exception IOException If an error occurs + */ public void flush() throws IOException { synchronized (lock) @@ -186,6 +210,13 @@ public class OutputStreamWriter extends Writer } } + /** + * This method writes a single character to the output stream. + * + * @param c The char to write, passed as an int. + * + * @exception IOException If an error occurs + */ public void write(int ch) throws IOException { synchronized (lock) @@ -203,4 +234,6 @@ public class OutputStreamWriter extends Writer work[wcount++] = (char) ch; } } -} + +} // class OutputStreamWriter + diff --git a/libjava/java/io/PrintStream.java b/libjava/java/io/PrintStream.java index 3101bb5..8fc1cb8 100644 --- a/libjava/java/io/PrintStream.java +++ b/libjava/java/io/PrintStream.java @@ -55,12 +55,30 @@ public class PrintStream extends FilterOutputStream * This leads to some minor duplication, because neither inherits * from the other, and we want to maximize performance. */ + public PrintStream (OutputStream out) + { + this(out, false); + } + + public PrintStream (OutputStream out, boolean auto_flush) + { + super(out); + converter = UnicodeToBytes.getDefaultEncoder(); + error = false; + this.auto_flush = auto_flush; + } + public boolean checkError () { flush(); return error; } + protected void setError () + { + error = true; + } + public void close () { try @@ -258,24 +276,6 @@ public class PrintStream extends FilterOutputStream print(charArray, 0, charArray.length, true); } - public PrintStream (OutputStream out) - { - this(out, false); - } - - public PrintStream (OutputStream out, boolean af) - { - super(out); - converter = UnicodeToBytes.getDefaultEncoder(); - error = false; - auto_flush = af; - } - - protected void setError () - { - error = true; - } - public void write (int oneByte) { try |