From: <hag...@us...> - 2006-12-14 10:06:40
|
Revision: 2914 http://jnode.svn.sourceforge.net/jnode/?rev=2914&view=rev Author: hagar-wize Date: 2006-12-14 02:06:39 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Classpath patches Modified Paths: -------------- trunk/core/src/classpath/java/java/io/FileDescriptor.java trunk/core/src/classpath/java/java/io/FileInputStream.java Modified: trunk/core/src/classpath/java/java/io/FileDescriptor.java =================================================================== --- trunk/core/src/classpath/java/java/io/FileDescriptor.java 2006-12-14 10:05:45 UTC (rev 2913) +++ trunk/core/src/classpath/java/java/io/FileDescriptor.java 2006-12-14 10:06:39 UTC (rev 2914) @@ -134,6 +134,7 @@ */ public boolean valid () { - return channel != null && channel.isOpen(); + ByteChannel c = channel; + return (c != null) && (c.isOpen()); } } Modified: trunk/core/src/classpath/java/java/io/FileInputStream.java =================================================================== --- trunk/core/src/classpath/java/java/io/FileInputStream.java 2006-12-14 10:05:45 UTC (rev 2913) +++ trunk/core/src/classpath/java/java/io/FileInputStream.java 2006-12-14 10:06:39 UTC (rev 2914) @@ -38,8 +38,9 @@ package java.io; -import gnu.java.nio.channels.FileChannelImpl; +import gnu.java.nio.FileChannelImpl; +import java.nio.ByteBuffer; import java.nio.channels.FileChannel; /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 @@ -107,8 +108,21 @@ if (s != null) s.checkRead(file.getPath()); + try + { ch = FileChannelImpl.create(file, FileChannelImpl.READ); } + catch (FileNotFoundException fnfe) + { + throw fnfe; + } + catch (IOException ioe) + { + FileNotFoundException fnfe = new FileNotFoundException(file.getPath()); + fnfe.initCause(ioe); + throw fnfe; + } + } /** * This method initializes a <code>FileInputStream</code> to read from the @@ -266,7 +280,7 @@ || offset + len > buf.length) throw new ArrayIndexOutOfBoundsException(); - return ch.read(buf, offset, len); + return ch.read(ByteBuffer.wrap(buf, offset, len)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |