src/share/classes/java/io/FileInputStream.java

Print this page




  25 
  26 package java.io;
  27 
  28 import java.nio.channels.FileChannel;
  29 import sun.nio.ch.FileChannelImpl;
  30 
  31 
  32 /**
  33  * A <code>FileInputStream</code> obtains input bytes
  34  * from a file in a file system. What files
  35  * are  available depends on the host environment.
  36  *
  37  * <p><code>FileInputStream</code> is meant for reading streams of raw bytes
  38  * such as image data. For reading streams of characters, consider using
  39  * <code>FileReader</code>.
  40  *
  41  * @author  Arthur van Hoff
  42  * @see     java.io.File
  43  * @see     java.io.FileDescriptor
  44  * @see     java.io.FileOutputStream

  45  * @since   JDK1.0
  46  */
  47 public
  48 class FileInputStream extends InputStream
  49 {
  50     /* File Descriptor - handle to the open file */
  51     private final FileDescriptor fd;
  52 
  53     private FileChannel channel = null;
  54 
  55     private final Object closeLock = new Object();
  56     private volatile boolean closed = false;
  57 
  58     private static final ThreadLocal<Boolean> runningFinalize =
  59         new ThreadLocal<>();
  60 
  61     private static boolean isRunningFinalize() {
  62         Boolean val;
  63         if ((val = runningFinalize.get()) != null)
  64             return val.booleanValue();




  25 
  26 package java.io;
  27 
  28 import java.nio.channels.FileChannel;
  29 import sun.nio.ch.FileChannelImpl;
  30 
  31 
  32 /**
  33  * A <code>FileInputStream</code> obtains input bytes
  34  * from a file in a file system. What files
  35  * are  available depends on the host environment.
  36  *
  37  * <p><code>FileInputStream</code> is meant for reading streams of raw bytes
  38  * such as image data. For reading streams of characters, consider using
  39  * <code>FileReader</code>.
  40  *
  41  * @author  Arthur van Hoff
  42  * @see     java.io.File
  43  * @see     java.io.FileDescriptor
  44  * @see     java.io.FileOutputStream
  45  * @see     java.nio.file.Files#newInputStream
  46  * @since   JDK1.0
  47  */
  48 public
  49 class FileInputStream extends InputStream
  50 {
  51     /* File Descriptor - handle to the open file */
  52     private final FileDescriptor fd;
  53 
  54     private FileChannel channel = null;
  55 
  56     private final Object closeLock = new Object();
  57     private volatile boolean closed = false;
  58 
  59     private static final ThreadLocal<Boolean> runningFinalize =
  60         new ThreadLocal<>();
  61 
  62     private static boolean isRunningFinalize() {
  63         Boolean val;
  64         if ((val = runningFinalize.get()) != null)
  65             return val.booleanValue();