JavaQuick Tip: Finding Hidden Files Using Java

Quick Tip: Finding Hidden Files Using Java content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Java Developer Tutorials

In this programming tutorial and quick tip, Java developers will learn how to find hidden files and uncover whether or not a file is hidden. Here is a quick Java code example of how to find a particular hidden file:


import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;

public class ChkIfFileIsHidden
	public static void main(String args[])
		ChkIfFileIsHidden chkIfFileIsHidden = new ChkIfFileIsHidden();
	private void proceed()
			Path currDirAndFile = Paths.get("./a.txt"); //Create a file a.txt and set its properties to hidden
			System.out.println("Files.isHidden(" + currDirAndFile + "): " + Files.isHidden(currDirAndFile));
		}catch(IOException ioe)
			System.out.println("Exception: " + ioe);


You can expect the following output if you run this Java code in your IDE or code editor:

[root@mypc]# java ChkIfFileIsHidden
Files.isHidden(.\a.txt): true

Read more Java programming tutorials and how-tos.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories