39 |
package java.io; |
package java.io; |
40 |
|
|
41 |
import gnu.classpath.Configuration; |
import gnu.classpath.Configuration; |
42 |
|
import java.nio.channels.FileChannel; |
43 |
|
import gnu.java.nio.FileChannelImpl; |
44 |
|
|
45 |
/** |
/** |
46 |
* This class is a stream that reads its bytes from a file. |
* This class is a stream that reads its bytes from a file. |
443 |
close(); |
close(); |
444 |
} |
} |
445 |
|
|
446 |
|
|
447 |
|
/*************************************************************************/ |
448 |
|
|
449 |
|
/** |
450 |
|
* This method creates a java.nio.channels.FileChannel. |
451 |
|
* Nio does not allow one to create a file channel directly. |
452 |
|
* A file channel must be created by first creating an instance of |
453 |
|
* Input/Output/RandomAccessFile and invoking the getChannel() method on it. |
454 |
|
*/ |
455 |
|
|
456 |
|
private FileChannel ch; /* cached associated file-channel */ |
457 |
|
|
458 |
|
public FileChannel |
459 |
|
getChannel() |
460 |
|
{ |
461 |
|
synchronized (this) |
462 |
|
{ |
463 |
|
if (ch == null) |
464 |
|
ch = new gnu.java.nio.FileChannelImpl(native_fd, |
465 |
|
this); |
466 |
|
} |
467 |
|
return ch; |
468 |
|
} |
469 |
|
|
470 |
|
|
471 |
} // class FileInputStream |
} // class FileInputStream |
472 |
|
|