<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileHandle/init(forReadingAtPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileHandle(cm)fileHandleForReadingAtPath:"
  },
  "title" : "init(forReadingAtPath:)"
}
-->

# init(forReadingAtPath:)

Returns a file handle initialized for reading the file, device, or named socket at the specified path.

```
convenience init?(forReadingAtPath path: String)
```

## Parameters

`path`

The path to the file, device, or named socket to access.

## Return Value

The initialized file handle object or `nil` if no file exists at `path`.

## Discussion

The system sets the file pointer to the beginning of the file. You can’t write data to the returned file handle object. Use the [`readDataToEndOfFile()`](/documentation/Foundation/FileHandle/readDataToEndOfFile()) or [`readData(ofLength:)`](/documentation/Foundation/FileHandle/readData(ofLength:)) methods to read data from it.

When using this method to create a file handle object, the file handle owns its associated file descriptor and is responsible for closing it.

## See Also

[`availableData`](/documentation/Foundation/FileHandle/availableData)

The data currently available in the receiver.

[`readData(ofLength:)`](/documentation/Foundation/FileHandle/readData(ofLength:))

Reads data synchronously up to the specified number of bytes.

[`readDataToEndOfFile()`](/documentation/Foundation/FileHandle/readDataToEndOfFile())

Reads the available data synchronously up to the end of file or maximum number of bytes.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)