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
This commit is contained in:
parent
6db450f90a
commit
950ebbeaf0
@ -1,3 +1,30 @@
|
||||
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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user