鸿蒙OS开发文档 鸿蒙OS FileNotFoundException

2024-02-25 开发教程 鸿蒙OS开发文档 匿名 4

FileNotFoundException

java.lang.Object
|---java.lang.Throwable
|---|---java.lang.Exception
|---|---|---java.io.IOException
|---|---|---|---java.io.FileNotFoundException

public class FileNotFoundException
extends IOException

表示尝试打开由指定路径名表示的文件失败的信号。

当具有指定路径名的文件不存在时,FileInputStream、FileOutputStream 和 RandomAccessFile 构造函数将引发此异常。 如果文件确实存在但由于某种原因不可访问,例如当试图打开只读文件进行写入时,这些构造函数也会抛出它。

Since:

JDK1.0

构造函数摘要

构造函数描述
FileNotFoundException()构造一个以 null 作为其错误详细消息的 FileNotFoundException。
FileNotFoundException(String s)使用指定的详细消息构造 FileNotFoundException。

方法总结

从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从类 java.lang.Throwable 继承的方法
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

构造函数详细信息

FileNotFoundException

public FileNotFoundException()

构造一个以 null 作为其错误详细消息的 FileNotFoundException。

FileNotFoundException

public FileNotFoundException(String s)

使用指定的详细消息构造 FileNotFoundException。 字符串 s 可以稍后通过 java.lang.Throwable 类的 Throwable.getMessage() 方法检索。

参数:

参数名称参数描述
s详细信息。