Skip to content

Example code using System.err instead of System.out #268

Description

@authentictech

In Tutorials > The Java I/O API > File System Basics > Creating and Reading Directories, section "Listing a File System's Root Directories", the code prints to System.err instead of System.out when it is not printing an error.

Iterable<Path> dirs = FileSystems.getDefault().getRootDirectories();
for (Path name: dirs) {
    System.err.println(name);
}

Activity

  1. authentictech commented on Aug 4, 2026

    @authentictech
    Author

    On the same page, I've noticed that the wrong variable is used in the code in "Creating a Directory":

    Path dir = ...;
    Files.createDirectory(path); // should be dir
    
  2. willy-b commented on Aug 4, 2026

    @willy-b

    Good find! As a fellow volunteer reporting similar issues I am noting that the mismatched variable and System.err usage you report here dates back to at least 2025 (see https://web.archive.org/web/20250605060428/https://dev.java/learn/java-io/file-system/creating-reading-directories/ ) and is not from or related to the changes I recommended to this tutorial series recently in #210 (comment) which were made by the dev.java team. Thanks!

  3. JosePaumard commented on Aug 5, 2026

    @JosePaumard
    Contributor

    Thanks to both of you! You guys rock! A fix is on its way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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