If you’re using Java 7 you can use the new java.nio.file.attribute
package like so:
Path path = FileSystems.getDefault().getPath("/j", "sa");
Files.setAttribute(path, "dos:hidden", true);
See more info at http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html
Or, if you’re using an older version of Java and/or want to do it using Runtime
, try this:
Process process = Runtime.getRuntime().exec("cmd.exe /C attrib -s -h -r your_path");