我不确定这是否可行但有人知道是否可以将变量传递给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
任何帮助都会很棒。提前谢谢。
答案 0 :(得分:2)
你实际上是在构建一个字符串。
for (int x=0;x<MAX;x++){
String command = "cmd /c curl command -o \"file" + x + ".png\"";
// use it!
}