1

我尝试了以下语法:

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 调用。为什么会这样?

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

4

0 回答 0