Skip to content

Example code in File Systems Basics tutorial needs a try block #266

Description

@authentictech

In Learn > The Java I/O API > File System Basics > Manipulating Files and Directories, section "Checking Whether Two Paths Locate the Same File" the code below needs a try block as it throws IOException.

if (Files.isSameFile(p1, p2)) {
    // Logic when the paths locate the same file
}

Possibly trivial, as it's small and incomplete code example, but it might still aid understanding to know that is required. I also expanded the code example to try some things out, which others may also do, so would save a bit of time to include upfront.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions