| 构造方法 |
|---|
| FileReader(File file)
创建一个新的 FileReader ,给出 File读取。 |
| FileReader(FileDescriptor fd)
创建一个新的 FileReader ,给定 FileDescriptor读取。 |
| FileReader(String fileName)
创建一个新的 FileReader ,给定要读取的文件的名称 |
| Modifier and Type | Method and Description |
|---|---|
| void | close()
关闭流并释放与之相关联的任何系统资源。 |
| String | getEncoding()
返回此流使用的字符编码的名称。 |
| int | read()
读一个字符 |
| int | read(char[] cbuf, int offset, int length)
将字符读入数组的一部分。 |
| boolean | ready()
告诉这个流是否准备好被读取 |
|
| Modifier and Type | Method and Description |
|---|---|
| protected Object | clone()
创建并返回此对象的副本。 |
| boolean | equals(Object obj)
指示一些其他对象是否等于此。 |
| protected void | finalize()
当垃圾收集确定不再有对该对象的引用时,垃圾收集器在对象上调用该对象。 |
| 类<?> | getClass()
返回此 Object的运行时类。 |
| int | hashCode()
返回对象的哈希码值。 |
| void | notify()
唤醒正在等待对象监视器的单个线程。 |
| void | notifyAll()
唤醒正在等待对象监视器的所有线程。 |
| String | toString()
返回对象的字符串表示形式。 |
| void | wait()
导致当前线程等待,直到另一个线程调用该对象的 notify()方法或 notifyAll()方法。 |
| void | wait(long timeout)
导致当前线程等待,直到另一个线程调用 notify()方法或该对象的 notifyAll()方法,或者指定的时间已过。 |
| void | wait(long timeout, int nanos)
导致当前线程等待,直到另一个线程调用该对象的 notify()方法或 notifyAll()方法,或者某些其他线程中断当前线程,或一定量的实时时间。 |
File file = new File("Hello.txt");
FileReader fr = new FileReader(file);// 构建读取流
char[] a = new char[50]; //定义一个保存内容的数组
fr.read(a); // 将内容读取到数组中
for (char c : a)
System.out.print(c); // 打印字符
fr.close();