summaryrefslogtreecommitdiff
path: root/java/io/RandomAccessFile.java
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2005-04-29 16:57:05 +0000
committerMark Wielaard <mark@klomp.org>2005-04-29 16:57:05 +0000
commit482077092ade857677d3e918afe869c9e923b3e4 (patch)
tree1241343b8c61f7805aa6810d70da17cbd06733dc /java/io/RandomAccessFile.java
parentddeb4663884c7c06a0be469b7cdbe5d2a406f326 (diff)
downloadclasspath-482077092ade857677d3e918afe869c9e923b3e4.tar.gz
2005-04-29 Dalibor Topic <robilad@kaffe.org>
* java/nio/channels/FileChannelImpl.java (FileChannelImpl(Sting, int)): Removed. (FileChannelImpl(File, int)) Added. Check if opened file is a directory. * java/io/FileInputStream.java(FileInputStream): Fixed javadocs. Call FileChannelImpl(File, int). * java/io/FileOutputStream.java (FileInputStream): Call FileChannelImpl(File, int). * java/io/RandomAccessFile.java (RandomAccessFile): Call FileChannelImpl(File, int). Switched constructors around.
Diffstat (limited to 'java/io/RandomAccessFile.java')
-rw-r--r--java/io/RandomAccessFile.java62
1 files changed, 33 insertions, 29 deletions
diff --git a/java/io/RandomAccessFile.java b/java/io/RandomAccessFile.java
index c23ca3adf..ef367949a 100644
--- a/java/io/RandomAccessFile.java
+++ b/java/io/RandomAccessFile.java
@@ -86,38 +86,12 @@ public class RandomAccessFile implements DataOutput, DataInput
* illegal value
* @exception SecurityException If the requested access to the file
* is not allowed
- * @exception IOException If any other error occurs
+ * @exception FileNotFoundException If the file is a directory, or
+ * any other error occurs
*/
public RandomAccessFile (File file, String mode)
throws FileNotFoundException
{
- this (file.getPath(), mode);
- }
-
- /**
- * This method initializes a new instance of <code>RandomAccessFile</code>
- * to read from the specified file name with the specified access mode.
- * The access mode is either "r" for read only access, "rw" for read
- * write access, "rws" for synchronized read/write access of both
- * content and metadata, or "rwd" for read/write access
- * where only content is required to be synchronous.
- * <p>
- * Note that a <code>SecurityManager</code> check is made prior to
- * opening the file to determine whether or not this file is allowed to
- * be read or written.
- *
- * @param fileName The name of the file to read and/or write
- * @param mode "r", "rw", "rws", or "rwd"
- *
- * @exception IllegalArgumentException If <code>mode</code> has an
- * illegal value
- * @exception SecurityException If the requested access to the file
- * is not allowed
- * @exception FileNotFoundException If any other error occurs
- */
- public RandomAccessFile (String fileName, String mode)
- throws FileNotFoundException
- {
int fdmode;
if (mode.equals("r"))
fdmode = FileChannelImpl.READ;
@@ -136,6 +110,8 @@ public class RandomAccessFile implements DataOutput, DataInput
else
throw new IllegalArgumentException ("invalid mode: " + mode);
+ final String fileName = file.getPath();
+
// The obligatory SecurityManager stuff
SecurityManager s = System.getSecurityManager();
if (s != null)
@@ -146,13 +122,41 @@ public class RandomAccessFile implements DataOutput, DataInput
s.checkWrite(fileName);
}
- ch = new FileChannelImpl (fileName, fdmode);
+ ch = new FileChannelImpl (file, fdmode);
fd = new FileDescriptor(ch);
out = new DataOutputStream (new FileOutputStream (fd));
in = new DataInputStream (new FileInputStream (fd));
}
/**
+ * This method initializes a new instance of <code>RandomAccessFile</code>
+ * to read from the specified file name with the specified access mode.
+ * The access mode is either "r" for read only access, "rw" for read
+ * write access, "rws" for synchronized read/write access of both
+ * content and metadata, or "rwd" for read/write access
+ * where only content is required to be synchronous.
+ * <p>
+ * Note that a <code>SecurityManager</code> check is made prior to
+ * opening the file to determine whether or not this file is allowed to
+ * be read or written.
+ *
+ * @param fileName The name of the file to read and/or write
+ * @param mode "r", "rw", "rws", or "rwd"
+ *
+ * @exception IllegalArgumentException If <code>mode</code> has an
+ * illegal value
+ * @exception SecurityException If the requested access to the file
+ * is not allowed
+ * @exception FileNotFoundException If the file is a directory or
+ * any other error occurs
+ */
+ public RandomAccessFile (String fileName, String mode)
+ throws FileNotFoundException
+ {
+ this (new File(fileName), mode);
+ }
+
+ /**
* This method closes the file and frees up all file related system
* resources. Since most operating systems put a limit on how many files
* may be opened at any given time, it is a good idea to close all files