FileReader.java 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* FileReader.java -- Convenience class for reading characters from a file
  2. Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.io;
  32. /**
  33. * This class provides a convenient way to set up a <code>Reader</code>
  34. * to read from a file. It opens the specified file for reading and creates
  35. * the <code>InputStreamReader</code> to read from the
  36. * resulting <code>FileInputStream</code>. This class can only be used
  37. * to read from files using the default character encoding. Use
  38. * <code>InputStreamReader</code> directly to use a non-default encoding.
  39. *
  40. * @author Aaron M. Renn (arenn@urbanophile.com)
  41. */
  42. public class FileReader extends InputStreamReader
  43. {
  44. /**
  45. * This method initializes a <code>FileReader</code> instance to read from
  46. * the specified <code>File</code> object.
  47. *
  48. * @param file The <code>File</code> object representing the file to read from
  49. *
  50. * @exception FileNotFoundException If the file is not found or some other
  51. * error occurs
  52. */
  53. public FileReader(File file) throws FileNotFoundException
  54. {
  55. super(new FileInputStream(file));
  56. }
  57. /**
  58. * This method initializes a <code>FileReader</code> instance to read from
  59. * this specified <code>FileDescriptor</code> object.
  60. *
  61. * @param fd The <code>FileDescriptor</code> to read from.
  62. */
  63. public FileReader(FileDescriptor fd)
  64. {
  65. super(new FileInputStream(fd));
  66. }
  67. /**
  68. * This method initializes a <code>FileReader</code> instance to read from
  69. * the specified named file.
  70. *
  71. * @param name The name of the file to read from
  72. *
  73. * @exception FileNotFoundException If the file is not found or some other
  74. * error occurs
  75. */
  76. public FileReader(String name) throws FileNotFoundException
  77. {
  78. super(new FileInputStream(name));
  79. }
  80. } // class FileReader