Stay organized with collections
Save and categorize content based on your preferences.
FileNotFoundException
open class FileNotFoundException : IOException
Signals that an attempt to open the file denoted by a specified pathname has failed.
This exception will be thrown by the FileInputStream
, FileOutputStream
, and RandomAccessFile
constructors when a file with the specified pathname does not exist. It will also be thrown by these constructors if the file does exist but for some reason is inaccessible, for example when an attempt is made to open a read-only file for writing.
Summary
Public constructors |
Constructs a FileNotFoundException with null as its error detail message.
|
Constructs a FileNotFoundException with the specified detail message.
|
Public constructors
FileNotFoundException
FileNotFoundException()
Constructs a FileNotFoundException
with null
as its error detail message.
FileNotFoundException
FileNotFoundException(s: String!)
Constructs a FileNotFoundException
with the specified detail message. The string s
can be retrieved later by the java.lang.Throwable#getMessage
method of class java.lang.Throwable
.
Parameters |
s |
String!: the detail message. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# FileNotFoundException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nFileNotFoundException\n=====================\n\n```\nopen class FileNotFoundException : IOException\n```\n\n|---|---|---|---|------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||||\n| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) ||||\n| | ↳ | [java.lang.Exception](../lang/Exception.html#) |||\n| | | ↳ | [java.io.IOException](/reference/kotlin/java/io/IOException) ||\n| | | | ↳ | [java.io.FileNotFoundException](#) |\n\nSignals that an attempt to open the file denoted by a specified pathname has failed.\n\nThis exception will be thrown by the [FileInputStream](/reference/kotlin/java/io/FileInputStream), [FileOutputStream](/reference/kotlin/java/io/FileOutputStream), and [RandomAccessFile](/reference/kotlin/java/io/RandomAccessFile) constructors when a file with the specified pathname does not exist. It will also be thrown by these constructors if the file does exist but for some reason is inaccessible, for example when an attempt is made to open a read-only file for writing.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [FileNotFoundException](#FileNotFoundException())`()` Constructs a `FileNotFoundException` with `null` as its error detail message. |\n| [FileNotFoundException](#FileNotFoundException(kotlin.String))`(`s:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Constructs a `FileNotFoundException` with the specified detail message. |\n\nPublic constructors\n-------------------\n\n### FileNotFoundException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nFileNotFoundException()\n```\n\nConstructs a `FileNotFoundException` with `null` as its error detail message. \n\n### FileNotFoundException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nFileNotFoundException(s: String!)\n```\n\nConstructs a `FileNotFoundException` with the specified detail message. The string `s` can be retrieved later by the [java.lang.Throwable#getMessage](../lang/Throwable.html#getMessage()) method of class `java.lang.Throwable`.\n\n| Parameters ||\n|-----|--------------------------------------------------------------------------------------------------------|\n| `s` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the detail message. |"]]