File.java: Import needed classes instead of whole packages...
2003-03-28 Michael Koch <konqueror@gmx.de> * java/io/File.java: Import needed classes instead of whole packages, merged class documentation with classpath, moved constants and variables to top of class. * java/io/PrintStream.java: Merged class documentation with classpath, moved constants and variables to top of class. * java/io/RandomAccessFile.java (RandomAccessFile): Merged with classpath. (read): Merged with classpath). (read*): Reformatted. From-SVN: r64974
This commit is contained in:
parent
bcfaead06e
commit
01312d1259
|
@ -1,3 +1,17 @@
|
|||
2003-03-28 Michael Koch <konqueror@gmx.de>
|
||||
|
||||
* java/io/File.java:
|
||||
Import needed classes instead of whole packages, merged class
|
||||
documentation with classpath, moved constants and variables to top of
|
||||
class.
|
||||
* java/io/PrintStream.java:
|
||||
Merged class documentation with classpath, moved constants and
|
||||
variables to top of class.
|
||||
* java/io/RandomAccessFile.java
|
||||
(RandomAccessFile): Merged with classpath.
|
||||
(read): Merged with classpath).
|
||||
(read*): Reformatted.
|
||||
|
||||
2003-03-28 Michael Koch <konqueror@gmx.de>
|
||||
|
||||
* java/io/FileDescriptor.java
|
||||
|
|
|
@ -38,22 +38,49 @@ exception statement from your version. */
|
|||
|
||||
package java.io;
|
||||
|
||||
import java.util.*;
|
||||
import java.net.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import gnu.gcj.runtime.FileDeleter;
|
||||
|
||||
/**
|
||||
* @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.3.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class represents a file or directory on a local disk. It provides
|
||||
* facilities for dealing with a variety of systems that use various
|
||||
* types of path separators ("/" versus "\", for example). It also
|
||||
* contains method useful for creating and deleting files and directories.
|
||||
*
|
||||
* @author Aaron M. Renn <arenn@urbanophile.com>
|
||||
* @author Tom Tromey <tromey@cygnus.com>
|
||||
*/
|
||||
public class File implements Serializable, Comparable
|
||||
{
|
||||
private static final long serialVersionUID = 301077366599181567L;
|
||||
|
||||
// QUERY arguments to access function.
|
||||
private final static int READ = 0;
|
||||
private final static int WRITE = 1;
|
||||
private final static int EXISTS = 2;
|
||||
|
||||
// QUERY arguments to stat function.
|
||||
private final static int DIRECTORY = 0;
|
||||
private final static int ISFILE = 1;
|
||||
private final static int ISHIDDEN = 2;
|
||||
|
||||
// QUERY arguments to attr function.
|
||||
private final static int MODIFIED = 0;
|
||||
private final static int LENGTH = 1;
|
||||
|
||||
private final native long attr (int query);
|
||||
// On OSF1 V5.0, `stat' is a macro. It is easiest to use the name
|
||||
// `_stat' instead. We do the same thing for `_access' just in
|
||||
// case.
|
||||
private final native boolean _access (int query);
|
||||
private final native boolean _stat (int query);
|
||||
|
||||
public boolean canRead ()
|
||||
{
|
||||
checkRead();
|
||||
|
@ -612,26 +639,4 @@ public class File implements Serializable, Comparable
|
|||
path = path.replace (oldSeparatorChar, separatorChar);
|
||||
}
|
||||
|
||||
// QUERY arguments to access function.
|
||||
private final static int READ = 0;
|
||||
private final static int WRITE = 1;
|
||||
private final static int EXISTS = 2;
|
||||
|
||||
// QUERY arguments to stat function.
|
||||
private final static int DIRECTORY = 0;
|
||||
private final static int ISFILE = 1;
|
||||
private final static int ISHIDDEN = 2;
|
||||
|
||||
// QUERY arguments to attr function.
|
||||
private final static int MODIFIED = 0;
|
||||
private final static int LENGTH = 1;
|
||||
|
||||
private final native long attr (int query);
|
||||
// On OSF1 V5.0, `stat' is a macro. It is easiest to use the name
|
||||
// `_stat' instead. We do the same thing for `_access' just in
|
||||
// case.
|
||||
private final native boolean _access (int query);
|
||||
private final native boolean _stat (int query);
|
||||
|
||||
private static final long serialVersionUID = 301077366599181567L;
|
||||
}
|
||||
|
|
|
@ -37,24 +37,55 @@ exception statement from your version. */
|
|||
|
||||
|
||||
package java.io;
|
||||
import gnu.gcj.convert.UnicodeToBytes;
|
||||
|
||||
/**
|
||||
* @author Tom Tromey <tromey@cygnus.com>
|
||||
* @date September 24, 1998
|
||||
*/
|
||||
import gnu.gcj.convert.UnicodeToBytes;
|
||||
|
||||
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
|
||||
* "The Java Language Specification", ISBN 0-201-63451-1
|
||||
* Status: Believed complete and correct to 1.3
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class prints Java primitive values and object to a stream as
|
||||
* text. None of the methods in this class throw an exception. However,
|
||||
* errors can be detected by calling the <code>checkError()</code> method.
|
||||
* Additionally, this stream can be designated as "autoflush" when
|
||||
* created so that any writes are automatically flushed to the underlying
|
||||
* output sink when the current line is terminated.
|
||||
* <p>
|
||||
* <b>Note that this class is deprecated</b>. It exists for backward
|
||||
* compatibility only. New code should be written to use
|
||||
* <code>PrintWriter</code> instead.
|
||||
* <p>
|
||||
* This class converts char's into byte's using the system default encoding.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @author Aaron M. Renn <arenn@urbanophile.com>
|
||||
* @author Tom Tromey <tromey@cygnus.com>
|
||||
*/
|
||||
public class PrintStream extends FilterOutputStream
|
||||
{
|
||||
/* Notice the implementation is quite similar to OutputStreamWriter.
|
||||
* This leads to some minor duplication, because neither inherits
|
||||
* from the other, and we want to maximize performance. */
|
||||
|
||||
// Line separator string.
|
||||
private static final char[] line_separator
|
||||
= System.getProperty("line.separator").toCharArray();
|
||||
|
||||
UnicodeToBytes converter;
|
||||
|
||||
// Work buffer of characters for converter.
|
||||
char[] work = new char[100];
|
||||
// Work buffer of bytes where we temporarily keep converter output.
|
||||
byte[] work_bytes = new byte[100];
|
||||
|
||||
// True if error occurred.
|
||||
private boolean error;
|
||||
// True if auto-flush.
|
||||
private boolean auto_flush;
|
||||
|
||||
public PrintStream (OutputStream out)
|
||||
{
|
||||
this(out, false);
|
||||
|
@ -312,19 +343,4 @@ public class PrintStream extends FilterOutputStream
|
|||
}
|
||||
}
|
||||
|
||||
UnicodeToBytes converter;
|
||||
|
||||
// Work buffer of characters for converter.
|
||||
char[] work = new char[100];
|
||||
// Work buffer of bytes where we temporarily keep converter output.
|
||||
byte[] work_bytes = new byte[100];
|
||||
|
||||
// True if error occurred.
|
||||
private boolean error;
|
||||
// True if auto-flush.
|
||||
private boolean auto_flush;
|
||||
|
||||
// Line separator string.
|
||||
private static final char[] line_separator
|
||||
= System.getProperty("line.separator").toCharArray();
|
||||
}
|
||||
|
|
|
@ -87,7 +87,8 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
* is not allowed
|
||||
* @exception IOException If any other error occurs
|
||||
*/
|
||||
public RandomAccessFile (File file, String mode) throws FileNotFoundException
|
||||
public RandomAccessFile (File file, String mode)
|
||||
throws FileNotFoundException
|
||||
{
|
||||
this (file.getPath(), mode);
|
||||
}
|
||||
|
@ -102,7 +103,7 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
* opening the file to determine whether or not this file is allowed to
|
||||
* be read or written.
|
||||
*
|
||||
* @param name The name of the file to read and/or write
|
||||
* @param fileName The name of the file to read and/or write
|
||||
* @param mode "r" for read only or "rw" for read-write access to the file
|
||||
*
|
||||
* @exception IllegalArgumentException If <code>mode</code> has an
|
||||
|
@ -114,6 +115,11 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
public RandomAccessFile (String fileName, String mode)
|
||||
throws FileNotFoundException
|
||||
{
|
||||
// Check the mode
|
||||
if (!mode.equals("r") && !mode.equals("rw") && !mode.equals("rws") &&
|
||||
!mode.equals("rwd"))
|
||||
throw new IllegalArgumentException("Bad mode value: " + mode);
|
||||
|
||||
int fdmode;
|
||||
if (mode.compareTo ("r") == 0)
|
||||
fdmode = FileDescriptor.READ;
|
||||
|
@ -122,12 +128,14 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
else
|
||||
throw new IllegalArgumentException ("invalid mode: " + mode);
|
||||
|
||||
// The obligatory SecurityManager stuff
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
{
|
||||
s.checkRead(fileName);
|
||||
if ((fdmode & FileDescriptor.WRITE) != 0)
|
||||
s.checkWrite(fileName);
|
||||
s.checkRead(fileName);
|
||||
|
||||
if ((fdmode & FileDescriptor.WRITE) != 0)
|
||||
s.checkWrite(fileName);
|
||||
}
|
||||
|
||||
fd = new FileDescriptor (fileName, fdmode);
|
||||
|
@ -159,6 +167,7 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
{
|
||||
if (! fd.valid())
|
||||
throw new IOException ();
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -231,12 +240,12 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
*/
|
||||
public int read (byte[] buffer) throws IOException
|
||||
{
|
||||
return in.read(buffer);
|
||||
return in.read (buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* This methods reads up to <code>len</code> bytes from the file into the s
|
||||
* pecified array starting at position <code>offset</code> into the array.
|
||||
* This methods reads up to <code>len</code> bytes from the file into the
|
||||
* specified array starting at position <code>offset</code> into the array.
|
||||
*
|
||||
* @param buf The array to read the bytes into
|
||||
* @param offset The index into the array to start storing bytes
|
||||
|
@ -246,9 +255,9 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
*
|
||||
* @exception IOException If an error occurs
|
||||
*/
|
||||
public int read (byte[] buffer, int offset, int count) throws IOException
|
||||
public int read (byte[] buffer, int offset, int len) throws IOException
|
||||
{
|
||||
return in.read(buffer, offset, count);
|
||||
return in.read (buffer, offset, len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,7 +279,7 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
*/
|
||||
public final boolean readBoolean () throws IOException
|
||||
{
|
||||
return in.readBoolean();
|
||||
return in.readBoolean ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,7 +299,7 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
*/
|
||||
public final byte readByte () throws IOException
|
||||
{
|
||||
return in.readByte();
|
||||
return in.readByte ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -347,7 +356,7 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
*/
|
||||
public final double readDouble () throws IOException
|
||||
{
|
||||
return in.readDouble();
|
||||
return in.readDouble ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -412,7 +421,7 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
public final void readFully (byte[] buffer, int offset, int count)
|
||||
throws IOException
|
||||
{
|
||||
in.readFully(buffer, offset, count);
|
||||
in.readFully (buffer, offset, count);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -477,7 +486,7 @@ public class RandomAccessFile implements DataOutput, DataInput
|
|||
*/
|
||||
public final String readLine () throws IOException
|
||||
{
|
||||
return in.readLine();
|
||||
return in.readLine ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue