diff options
Diffstat (limited to 'gnu/java/nio/channels/FileChannelImpl.java')
-rw-r--r-- | gnu/java/nio/channels/FileChannelImpl.java | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/gnu/java/nio/channels/FileChannelImpl.java b/gnu/java/nio/channels/FileChannelImpl.java index f3f60c3ec..1ae6960c1 100644 --- a/gnu/java/nio/channels/FileChannelImpl.java +++ b/gnu/java/nio/channels/FileChannelImpl.java @@ -88,9 +88,9 @@ public final class FileChannelImpl extends FileChannel init(); - in = new FileChannelImpl(0,READ); - out = new FileChannelImpl(1,WRITE); - err = new FileChannelImpl(2,WRITE); + in = new FileChannelImpl(0, READ); + out = new FileChannelImpl(1, WRITE); + err = new FileChannelImpl(2, WRITE); } /** @@ -105,6 +105,8 @@ public final class FileChannelImpl extends FileChannel private int mode; + final String description; + /* Open a file. MODE is a combination of the above mode flags. */ /* This is a static factory method, so that VM implementors can decide * substitute subclasses of FileChannelImpl. */ @@ -117,7 +119,8 @@ public final class FileChannelImpl extends FileChannel private FileChannelImpl(File file, int mode) throws FileNotFoundException { - final String path = file.getPath(); + String path = file.getPath(); + description = path; fd = open (path, mode); this.mode = mode; @@ -134,7 +137,7 @@ public final class FileChannelImpl extends FileChannel /* ignore it */ } - throw new FileNotFoundException(path + " is a directory"); + throw new FileNotFoundException(description + " is a directory"); } } @@ -151,6 +154,7 @@ public final class FileChannelImpl extends FileChannel { this.fd = fd; this.mode = mode; + this.description = "descriptor(" + fd + ")"; } private native int open (String path, int mode) throws FileNotFoundException; @@ -191,7 +195,7 @@ public final class FileChannelImpl extends FileChannel throws IOException { if (position < 0) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("position: " + position); long oldPosition = implPosition (); position (position); int result = read(dst); @@ -242,7 +246,7 @@ public final class FileChannelImpl extends FileChannel throws IOException { if (position < 0) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("position: " + position); if (!isOpen ()) throw new ClosedChannelException (); @@ -300,10 +304,11 @@ public final class FileChannelImpl extends FileChannel throw new NonWritableChannelException(); } else - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("mode: " + mode); if (position < 0 || size < 0 || size > Integer.MAX_VALUE) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("position: " + position + + ", size: " + size); return mapImpl(nmode, position, (int) size); } @@ -348,7 +353,8 @@ public final class FileChannelImpl extends FileChannel { if (position < 0 || count < 0) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("position: " + position + + ", count: " + count); if (!isOpen ()) throw new ClosedChannelException (); @@ -411,7 +417,8 @@ public final class FileChannelImpl extends FileChannel { if (position < 0 || count < 0) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("position: " + position + + ", count: " + count); if (!isOpen ()) throw new ClosedChannelException (); @@ -441,7 +448,8 @@ public final class FileChannelImpl extends FileChannel { if (position < 0 || size < 0) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("position: " + position + + ", size: " + size); if (!isOpen ()) throw new ClosedChannelException (); @@ -482,7 +490,8 @@ public final class FileChannelImpl extends FileChannel { if (position < 0 || size < 0) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("position: " + position + + ", size: " + size); if (!isOpen ()) throw new ClosedChannelException (); @@ -516,7 +525,7 @@ public final class FileChannelImpl extends FileChannel throws IOException { if (newPosition < 0) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("newPostition: " + newPosition); if (!isOpen ()) throw new ClosedChannelException (); @@ -531,7 +540,7 @@ public final class FileChannelImpl extends FileChannel throws IOException { if (size < 0) - throw new IllegalArgumentException (); + throw new IllegalArgumentException ("size: " + size); if (!isOpen ()) throw new ClosedChannelException (); @@ -544,4 +553,12 @@ public final class FileChannelImpl extends FileChannel return this; } + + public String toString() + { + return (this.getClass() + + "[fd=" + fd + + ",mode=" + mode + "," + + description + "]"); + } } |