Checking the File Visibility, to find out if a file is hidden - Java File Path IO

Java examples for File Path IO:File Attribute

Introduction

Call the Files.isHidden() method.

Demo Code

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
  public static void main(String[] args) {

    Path path = FileSystems.getDefault().getPath(
        "C:/folder1/folder2/folder4", "my.txt");
    try {//from  w w  w  .  j  a v  a2  s.  c  o  m
      boolean is_hidden = Files.isHidden(path);
      System.out.println("Is hidden ? " + is_hidden);
    } catch (IOException e) {
      System.err.println(e);
    }

  }
}

Result


Related Tutorials