如何在cacls中输入文件夹/文件的路径名和用户名/主机名

时间:2012-05-08 08:07:44

标签: java file file-permissions cacls

我尝试了以下语法:

public class Main {
private static String isi;

public static void main(String[] args) throws InterruptedException, IOException {

   String host = "";
   String dir = "" ;


    Scanner inputScanner = new Scanner(System.in);
    System.out.println("insert the path of folder or file:" );
    dir = inputScanner.next();
    File f = new File(dir);
  //  dir = isi;


    System.out.println("insert the username:"  );
    host = inputScanner.next();

    System.out.println();
    System.out.println();
    System.out.println(f);
    System.out.println(host);

    perm(f, host);
}

public static  void perm(File src, String user) throws InterruptedException, IOException {
    // win32 command line variant
    Process p = Runtime.getRuntime().exec("cacls " + src.getPath() + " /E /C /P " + user + ":n");
    p.waitFor(); }   }

但是,对象“f”和参数host没有被void perm调用。为什么会这样?

我需要你的帮助。我很感谢你的帮助和建议。

0 个答案:

没有答案