【问题标题】:Passing variables to java process将变量传递给java进程
【发布时间】:2015-10-22 15:02:32
【问题描述】:

我不确定这是否可行,但有谁知道是否可以将变量传递给 java 进程?

我的代码是:

Process process = Runtime.getRuntime().exec("cmd /c *curl command* -o "file.png");

我想看起来像这样:

int X = 0;

Process process = Runtime.getRuntime().exec("cmd /c *curl command* -o "fileX.png");

X++;

这样我可以得到如下输出:

file0.png

file1.png

file2.png

任何帮助都会很棒。提前致谢。

【问题讨论】:

  • 请努力写下这个问题,因为其他人正试图帮助你...参考stackoverflow.com/help/how-to-ask
  • 你的意思是像for (int i = 0;i<xxxx;++i) String filename = "File"+i+".png";?这样的循环
  • 是的!字符串连接。我会试试这个。谢谢。

标签: java windows curl process cmd


【解决方案1】:

你实际上是在构建一个字符串。

for (int x=0;x<MAX;x++){
    String command = "cmd /c curl command -o \"file" + x + ".png\"";
    // use it!
}

【讨论】:

    猜你喜欢
    • 2017-05-02
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 2016-03-26
    • 1970-01-01
    • 2017-03-20
    • 1970-01-01
    • 2019-08-29
    相关资源
    最近更新 更多