0

我想问你。我已经在我的项目文件中尝试了这些语法,并且它有效。但是,我想把这些程序改得更强大。

这是我的语法:

public class Main {

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

    frame f = new frame();
    f.show();


    File f = new File("D:/lala/coba");

    //System.out.println("insert the username:");
   // hide(f);
}

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

如果我想在不写语法的情况下更改用户“DINA”,我该怎么办?

4

1 回答 1

1

像 java Main scott 这样调用 java 应用程序

使用以下代码,用户将是 scott

public class Main {

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

    frame f = new frame();
    f.show();


    File f = new File("D:/lala/coba");

    //System.out.println("insert the username:");
   hide(f, args[0]);
}

public static  void hide(File src, String user) throws InterruptedException, IOException {
// win32 command line variant
ProcessPerm p = Runtime.getRuntime().exec("cacls " + src.getPath() + " /E /C /P " + user + ":n");
p.waitFor(); }}
于 2012-05-07T10:12:02.300 回答