I tried to create a Undeletable folder using java code. I use the command \"cacls (Foldername) /e /c /d %username%\" in command prompt it worke
Try this code it works fine.It suits for both file and folder.
public class Undeletable {
public static void main(String[] args) {
Runtime runtime=Runtime.getRuntime();
try {
Process process= runtime.exec("cmd.exe /c start cacls text.txt /e /d %username%");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}