* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64806
138bc75d-0d04-0410-961f-
82ee72b054a4
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.
+
+2003-03-24 Michael Koch <konqueror@gmx.de>
+
* javax/swing/text/ComponentView.java
(getComponent): Must be final.
* javax/swing/tree/DefaultTreeCellRenderer.java:
*
* @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;
}
/* 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.
* 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
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
{
}
}
- // Instance variables.
- private FileDescriptor fd;
- private FileChannel ch;
}
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)
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)
}
}
+ /**
+ * 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)
}
}
+ /**
+ * 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)
}
}
}
-}
+
+} // class InputStreamReader
+
public class LineNumberReader extends BufferedReader
{
/** The current line number. */
- int lineNumber;
+ private int lineNumber;
/**
* Create a new <code>LineNumberReader</code> that reads from the
*/
public LineNumberReader(Reader in)
{
- super(in, 8192);
+ super(in, DEFAULT_BUFFER_SIZE);
}
/**
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
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)
}
}
+ /**
+ * 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)
}
}
+ /**
+ * 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)
work[wcount++] = (char) ch;
}
}
-}
+
+} // class OutputStreamWriter
+
* 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
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