codecamp

鸿蒙OS FileReader

FileReader

java.lang.Object

|---java.io.Reader

|---|---java.io.InputStreamReader

|---|---|---java.io.FileReader

public class FileReader
extends InputStreamReader

读取字符文件的便利类。 此类的构造函数假定默认字符编码和默认字节缓冲区大小是适当的。 要自己指定这些值,请在 FileInputStream 上构造 InputStreamReader。

FileReader 用于读取字符流。 要读取原始字节流,请考虑使用 FileInputStream。

Since:

JDK1.1

字段摘要

从类 java.io.Reader 继承的字段
lock

构造函数摘要

构造函数 描述
FileReader(File file) 给定要读取的文件,创建一个新的 FileReader。
FileReader(FileDescriptor fd) 给定要读取的 FileDescriptor,创建一个新的 FileReader。
FileReader(String fileName) 给定要读取的文件的名称,创建一个新的 FileReader。

方法总结

从类 java.io.InputStreamReader 继承的方法
close, getEncoding, read, read, ready
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从类 java.io.Reader 继承的方法
mark, markSupported, read, read, reset, skip

构造函数详细信息

FileReader

public FileReader(String fileName) throws FileNotFoundException

给定要读取的文件的名称,创建一个新的 FileReader。

参数:

参数名称 参数描述
fileName 要读取的文件的名称

Throws:

Throw名称 Throw描述
FileNotFoundException 如果命名文件不存在,是目录而不是常规文件,或者由于某些其他原因无法打开读取。

FileReader

public FileReader(File file) throws FileNotFoundException

给定要读取的文件,创建一个新的 FileReader。

参数:

参数名称 参数描述
file 要读取的文件

Throws:

Throw名称 Throw描述
FileNotFoundException 如果文件不存在,是目录而不是常规文件,或者由于某些其他原因无法打开读取。

FileReader

public FileReader(FileDescriptor fd)

给定要读取的 FileDescriptor,创建一个新的 FileReader。

参数:

参数名称 参数描述
fd 要读取的 FileDescriptor
鸿蒙OS FilePermission
鸿蒙OS FileWriter
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

鸿蒙OS 开发

鸿蒙OS 术语

鸿蒙OS Java API参考

鸿蒙OS ohos.aafwk.ability

鸿蒙OS ohos.aafwk.abilityjet.activedata

鸿蒙OS ohos.aafwk.content

鸿蒙OS java.lang

鸿蒙OS java.Util

鸿蒙OS java.Util class

鸿蒙OS ohos.data.dataability

鸿蒙OS ohos.data.dataability class

鸿蒙OS ohos.agp.components

鸿蒙OS ohos.agp.components interface

鸿蒙OS ohos.agp.components class

鸿蒙OS ohos.global.configuration

鸿蒙OS java.io

鸿蒙OS ohos.data.resultset

鸿蒙OS ohos.data.resultset interface

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }