Commit 83f564f7 by Michael Koch Committed by Michael Koch

2003-05-06 Michael Koch <konqueror@gmx.de>

	* java/io/DataOutputStream.java
	(write): Renamed argument to "value", merged documentation from
	classpath.
	(writeBoolean): Likewise.
	(writeByte): Likewise.
	(writeShort): Likewise.
	(writeChar): Likewise.
	(writeInt): Likewise.
	(writeLong): Likewise.
	(writeFloat): Likewise.
	(writeDouble): Likewise.
	(writeBytes): Likewise.
	(writeChars): Likewise.
	(writeUTF): Likewise.
	* java/io/File.java
	(performDelete): Added documentation.
	(performList): Likewise.
	(performMkdir): Likewise.
	(performSetReadOnly): Likewise.
	(performRenameTo): Likewise.
	(performSetLastModified): Likewise.
	(delete): Made it sychronized.
	(renameTo): Made it sychronized.
	(equals): Reformatted.
	(isHidden): Likewise.
	(listFiles): Likewise.
	(setReadOnly): Likewise.
	(listRoots): Likewise.
	(setLastModified): Likewise.
	(checkRead): Likewise.
	(checkWrite): Likewise.
	* java/io/FileInputStream.java
	(skip): Made it sychronized, merged from classpath.
	* java/io/FileOutputStream.java
	(write): Merged from classpath.
	* java/io/InputStreamReader.java:
	(InputStreamReader): Merged documentation from classpath.

From-SVN: r66520
parent c2e39602
2003-05-06 Michael Koch <konqueror@gmx.de>
* java/io/DataOutputStream.java
(write): Renamed argument to "value", merged documentation from
classpath.
(writeBoolean): Likewise.
(writeByte): Likewise.
(writeShort): Likewise.
(writeChar): Likewise.
(writeInt): Likewise.
(writeLong): Likewise.
(writeFloat): Likewise.
(writeDouble): Likewise.
(writeBytes): Likewise.
(writeChars): Likewise.
(writeUTF): Likewise.
* java/io/File.java
(performDelete): Added documentation.
(performList): Likewise.
(performMkdir): Likewise.
(performSetReadOnly): Likewise.
(performRenameTo): Likewise.
(performSetLastModified): Likewise.
(delete): Made it sychronized.
(renameTo): Made it sychronized.
(equals): Reformatted.
(isHidden): Likewise.
(listFiles): Likewise.
(setReadOnly): Likewise.
(listRoots): Likewise.
(setLastModified): Likewise.
(checkRead): Likewise.
(checkWrite): Likewise.
* java/io/FileInputStream.java
(skip): Made it sychronized, merged from classpath.
* java/io/FileOutputStream.java
(write): Merged from classpath.
* java/io/InputStreamReader.java:
(InputStreamReader): Merged documentation from classpath.
2003-05-05 Michael Koch <konqueror@gmx.de>
* java/net/NetworkInterface.java
......
......@@ -199,7 +199,10 @@ public class File implements Serializable, Comparable
checkWrite();
return performCreate();
}
/*
* This native method handles the actual deleting of the file
*/
private native boolean performDelete ();
/**
......@@ -211,12 +214,13 @@ public class File implements Serializable, Comparable
*
* @exception SecurityException If deleting of the file is not allowed
*/
public boolean delete ()
public synchronized boolean delete ()
{
SecurityManager s = System.getSecurityManager();
String name = path;
SecurityManager s = System.getSecurityManager ();
if (s != null)
s.checkDelete(path);
s.checkDelete (path);
return performDelete ();
}
......@@ -239,11 +243,12 @@ public class File implements Serializable, Comparable
{
if (! (obj instanceof File))
return false;
File other = (File) obj;
if (caseSensitive)
return (path.equals(other.path));
return path.equals(other.path);
else
return (path.equalsIgnoreCase(other.path));
return path.equalsIgnoreCase(other.path);
}
/**
......@@ -663,7 +668,7 @@ public class File implements Serializable, Comparable
*
* @since 1.2
*/
public boolean isHidden()
public boolean isHidden ()
{
checkRead();
return _stat (ISHIDDEN);
......@@ -701,6 +706,11 @@ public class File implements Serializable, Comparable
checkRead();
return attr (LENGTH);
}
/*
* This native function actually produces the list of file in this
* directory
*/
private final native Object[] performList (FilenameFilter filter,
FileFilter fileFilter,
......@@ -781,7 +791,7 @@ public class File implements Serializable, Comparable
*
* @since 1.2
*/
public File[] listFiles()
public File[] listFiles ()
{
checkRead();
return (File[]) performList (null, null, File.class);
......@@ -811,12 +821,12 @@ public class File implements Serializable, Comparable
*
* @since 1.2
*/
public File[] listFiles(FilenameFilter filter)
public File[] listFiles (FilenameFilter filter)
{
checkRead();
return (File[]) performList (filter, null, File.class);
}
/**
* This method returns an array of <code>File</code> objects representing
* all the files in the directory represented by this object. If this
......@@ -841,7 +851,7 @@ public class File implements Serializable, Comparable
*
* @since 1.2
*/
public File[] listFiles(FileFilter filter)
public File[] listFiles (FileFilter filter)
{
checkRead();
return (File[]) performList (null, filter, File.class);
......@@ -880,6 +890,9 @@ public class File implements Serializable, Comparable
+ (isDirectory() ? "/" : ""));
}
/*
* This native method actually creates the directory
*/
private final native boolean performMkdir ();
/**
......@@ -1025,6 +1038,9 @@ public class File implements Serializable, Comparable
throw new IOException ("cannot create temporary file");
}
/*
* This native method sets the permissions to make the file read only.
*/
private native boolean performSetReadOnly();
/**
......@@ -1041,7 +1057,7 @@ public class File implements Serializable, Comparable
*
* @since 1.2
*/
public boolean setReadOnly()
public boolean setReadOnly ()
{
checkWrite();
return performSetReadOnly();
......@@ -1060,7 +1076,7 @@ public class File implements Serializable, Comparable
*
* @since 1.2
*/
public static File[] listRoots()
public static File[] listRoots ()
{
File[] roots = performListRoots();
......@@ -1180,6 +1196,9 @@ public class File implements Serializable, Comparable
return compareTo (other);
}
/*
* This native method actually performs the rename.
*/
private native boolean performRenameTo (File dest);
/**
......@@ -1194,7 +1213,7 @@ public class File implements Serializable, Comparable
* @exception SecurityException If write access is not allowed to the
* file by the <code>SecurityMananger</code>.
*/
public boolean renameTo (File dest)
public synchronized boolean renameTo (File dest)
{
SecurityManager s = System.getSecurityManager();
String sname = getName();
......@@ -1207,6 +1226,9 @@ public class File implements Serializable, Comparable
return performRenameTo (dest);
}
/*
* This method does the actual setting of the modification time.
*/
private native boolean performSetLastModified(long time);
/**
......@@ -1225,7 +1247,7 @@ public class File implements Serializable, Comparable
*
* @since 1.2
*/
public boolean setLastModified(long time)
public boolean setLastModified (long time)
{
checkWrite();
return performSetLastModified(time);
......@@ -1233,16 +1255,20 @@ public class File implements Serializable, Comparable
private void checkWrite ()
{
SecurityManager s = System.getSecurityManager();
// Check the SecurityManager
SecurityManager s = System.getSecurityManager ();
if (s != null)
s.checkWrite(path);
s.checkWrite (path);
}
private void checkRead ()
{
SecurityManager s = System.getSecurityManager();
// Check the SecurityManager
SecurityManager s = System.getSecurityManager ();
if (s != null)
s.checkRead(path);
s.checkRead (path);
}
/**
......@@ -1254,6 +1280,7 @@ public class File implements Serializable, Comparable
// FIXME: This should use the ShutdownHook API once we implement that.
public void deleteOnExit ()
{
// Check the SecurityManager
SecurityManager sm = System.getSecurityManager ();
if (sm != null)
sm.checkDelete (getName ());
......@@ -1275,8 +1302,9 @@ public class File implements Serializable, Comparable
// If the file was from an OS with a different dir separator,
// fixup the path to use the separator on this OS.
char oldSeparatorChar = ois.readChar ();
if (oldSeparatorChar != separatorChar)
path = path.replace (oldSeparatorChar, separatorChar);
}
} // class File
}
......@@ -82,6 +82,7 @@ public class FileInputStream extends InputStream
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkRead(name);
fd = new FileDescriptor(name, FileDescriptor.READ);
}
......@@ -268,15 +269,15 @@ public class FileInputStream extends InputStream
*
* @exception IOException If an error occurs
*/
public long skip (long numBytes) throws IOException
public synchronized long skip (long numBytes) throws IOException
{
if (numBytes < 0)
throw new IllegalArgumentException ( "Can't skip negative bytes: " +
numBytes);
throw new IllegalArgumentException ("Can't skip negative bytes: " +
numBytes);
if (numBytes == 0)
return 0;
long curPos = fd.getFilePointer ();
long newPos = fd.seek (numBytes, FileDescriptor.CUR, true);
return newPos - curPos;
......
......@@ -233,7 +233,7 @@ public class FileOutputStream extends OutputStream
public void write (byte[] buf)
throws IOException
{
fd.write (buf, 0, buf.length);
write (buf, 0, buf.length);
}
/**
......
......@@ -37,17 +37,54 @@ exception statement from your version. */
package java.io;
import gnu.gcj.convert.*;
/**
* This class reads characters from a byte input stream. The characters
* read are converted from bytes in the underlying stream by a
* decoding layer. The decoding layer transforms bytes to chars according
* to an encoding standard. There are many available encodings to choose
* from. The desired encoding can either be specified by name, or if no
* encoding is selected, 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 availalbe are "8859_1" (the Latin-1 character set) and "UTF8".
* Unforunately, Java does not provide a mechanism for listing the
* ecodings 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>
* <p>
* It is recommended that applications do not use
* <code>InputStreamReader</code>'s
* directly. Rather, for efficiency purposes, an object of this class
* should be wrapped by a <code>BufferedReader</code>.
* <p>
* Due to a deficiency the Java class library design, there is no standard
* way for an application to install its own byte-character encoding.
*
* @see BufferedReader
* @see InputStream
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Per Bothner <bothner@cygnus.com>
* @date April 22, 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 InputStreamReader extends Reader
{
BufferedInputStream in;
......@@ -61,11 +98,29 @@ public class InputStreamReader extends Reader
BytesToUnicode converter;
/**
* This method initializes a new instance of <code>InputStreamReader</code>
* to read from the specified stream using the default encoding.
*
* @param in The <code>InputStream</code> to read from
*/
public InputStreamReader(InputStream in)
{
this(in, BytesToUnicode.getDefaultDecoder());
}
/**
* This method initializes a new instance of <code>InputStreamReader</code>
* to read from 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 in The <code>InputStream</code> to read from
* @param encoding_name The name of the encoding scheme to use
*
* @exception UnsupportedEncodingException If the encoding scheme
* requested is not available.
*/
public InputStreamReader(InputStream in, String encoding_name)
throws UnsupportedEncodingException
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment