java examples
Home Java Examples Resources Java Interview Questions
Brainpower SEO

How to check if a file is hidden?

package com.javacoderanch.sample.java.io;

import java.io.File;
import java.io.IOException;

public class FileHiddenExample
{
    public static void main(String[] args) throws IOException
    {
        File file = new File("Hidden.txt");
        file.createNewFile();

        // We are using the isHidden() method to check whether file
        // specified file is hidden.
        if (file.isHidden())
        {
            System.out.println("File is hidden!");
        } else
        {
            System.out.println("File is not hidden!");
        }
    }
}