Search code examples
javafiledirectoryhidden

Make a File/Folder Hidden on Windows with Java


I need to make files and folders hidden on both Windows and Linux. I know that appending a '.' to the front of a file or folder will make it hidden on Linux. How do I make a file or folder hidden on Windows?


Solution

  • For Java 6 and below,

    You will need to use a native call, here is one way for windows

    Runtime.getRuntime().exec("attrib +H myHiddenFile.java");
    

    You should learn a bit about win32-api or Java Native.