Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/io/FileReader.java
38829 views
/*1* Copyright (c) 1996, 2001, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.io;262728/**29* Convenience class for reading character files. The constructors of this30* class assume that the default character encoding and the default byte-buffer31* size are appropriate. To specify these values yourself, construct an32* InputStreamReader on a FileInputStream.33*34* <p><code>FileReader</code> is meant for reading streams of characters.35* For reading streams of raw bytes, consider using a36* <code>FileInputStream</code>.37*38* @see InputStreamReader39* @see FileInputStream40*41* @author Mark Reinhold42* @since JDK1.143*/44public class FileReader extends InputStreamReader {4546/**47* Creates a new <tt>FileReader</tt>, given the name of the48* file to read from.49*50* @param fileName the name of the file to read from51* @exception FileNotFoundException if the named file does not exist,52* is a directory rather than a regular file,53* or for some other reason cannot be opened for54* reading.55*/56public FileReader(String fileName) throws FileNotFoundException {57super(new FileInputStream(fileName));58}5960/**61* Creates a new <tt>FileReader</tt>, given the <tt>File</tt>62* to read from.63*64* @param file the <tt>File</tt> to read from65* @exception FileNotFoundException if the file does not exist,66* is a directory rather than a regular file,67* or for some other reason cannot be opened for68* reading.69*/70public FileReader(File file) throws FileNotFoundException {71super(new FileInputStream(file));72}7374/**75* Creates a new <tt>FileReader</tt>, given the76* <tt>FileDescriptor</tt> to read from.77*78* @param fd the FileDescriptor to read from79*/80public FileReader(FileDescriptor fd) {81super(new FileInputStream(fd));82}8384}858687