Blogger

Delete comment from: Javarevisited

Shramik said...

We can set hidden attribute for DOS based OS (Windows) as below using NIO2 API

Path path = Paths.get("c:\sample");
Files.createFile(path);
Files.setAttribute(path, "dos:hidden", true);

or

DosFileAttributeView dosFileAttrView = Files.getFileAttributeView(path, DosFileAttributeView.class);
dosFileAttrView.setHidden(true);

We also can read this addribute using NIO2 API.

Apr 11, 2020, 10:15:04 AM


Posted to How to check if a File is hidden in Java? Example

Google apps
Main menu