< prev index next >

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

Print this page
rev 58552 : [mq]: 8241727-Typos-empty-lines-in-javadoc-inconsistent-indents-etc
   1 /*
   2  * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  35  * are  available depends on the host environment.
  36  *
  37  * <p>{@code FileInputStream} is meant for reading streams of raw bytes
  38  * such as image data. For reading streams of characters, consider using
  39  * {@code FileReader}.
  40  *
  41  * @apiNote
  42  * To release resources used by this stream {@link #close} should be called
  43  * directly or by try-with-resources. Subclasses are responsible for the cleanup
  44  * of resources acquired by the subclass.
  45  * Subclasses that override {@link #finalize} in order to perform cleanup
  46  * should be modified to use alternative cleanup mechanisms such as
  47  * {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
  48  *
  49  * @implSpec
  50  * If this FileInputStream has been subclassed and the {@link #close}
  51  * method has been overridden, the {@link #close} method will be
  52  * called when the FileInputStream is unreachable.
  53  * Otherwise, it is implementation specific how the resource cleanup described in
  54  * {@link #close} is performed.
  55 
  56  *
  57  * @author  Arthur van Hoff
  58  * @see     java.io.File
  59  * @see     java.io.FileDescriptor
  60  * @see     java.io.FileOutputStream
  61  * @see     java.nio.file.Files#newInputStream
  62  * @since   1.0
  63  */
  64 public class FileInputStream extends InputStream
  65 {
  66     /* File Descriptor - handle to the open file */
  67     private final FileDescriptor fd;
  68 
  69     /**
  70      * The path of the referenced file
  71      * (null if the stream is created with a file descriptor)
  72      */
  73     private final String path;
  74 
  75     private volatile FileChannel channel;


   1 /*
   2  * Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  35  * are  available depends on the host environment.
  36  *
  37  * <p>{@code FileInputStream} is meant for reading streams of raw bytes
  38  * such as image data. For reading streams of characters, consider using
  39  * {@code FileReader}.
  40  *
  41  * @apiNote
  42  * To release resources used by this stream {@link #close} should be called
  43  * directly or by try-with-resources. Subclasses are responsible for the cleanup
  44  * of resources acquired by the subclass.
  45  * Subclasses that override {@link #finalize} in order to perform cleanup
  46  * should be modified to use alternative cleanup mechanisms such as
  47  * {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
  48  *
  49  * @implSpec
  50  * If this FileInputStream has been subclassed and the {@link #close}
  51  * method has been overridden, the {@link #close} method will be
  52  * called when the FileInputStream is unreachable.
  53  * Otherwise, it is implementation specific how the resource cleanup described in
  54  * {@link #close} is performed.

  55  *
  56  * @author  Arthur van Hoff
  57  * @see     java.io.File
  58  * @see     java.io.FileDescriptor
  59  * @see     java.io.FileOutputStream
  60  * @see     java.nio.file.Files#newInputStream
  61  * @since   1.0
  62  */
  63 public class FileInputStream extends InputStream
  64 {
  65     /* File Descriptor - handle to the open file */
  66     private final FileDescriptor fd;
  67 
  68     /**
  69      * The path of the referenced file
  70      * (null if the stream is created with a file descriptor)
  71      */
  72     private final String path;
  73 
  74     private volatile FileChannel channel;


< prev index next >