我在使用Java Processbuilder运行批处理文件(" Input.bat")时遇到问题,但是当我通过命令提示符(批处理)运行它时它按预期工作:
img { cursor:pointer }
问题是它没有将输入参数值写入文件" Input.txt"当我通过Processbuilder运行时。批次肯定会被执行但不会写任何来自" ECHO%u%> INPUT.TXT"
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="page3">
<h1 align="right">generally i feel</h1>
<img src="http://www.iconsfind.com/wp-content/uploads/2013/11/20131105_527864817722b.png" id="tile1" value="1"/>
<img src="http://www.iconsfind.com/wp-content/uploads/2013/11/20131105_5278647a8cc0e.png" id="tile2" value="2"/>
<img src="http://www.iconsfind.com/wp-content/uploads/2013/11/20131105_5278647484ff1.png" id="tile3" value="3"/>
<img src="http://www.iconsfind.com/wp-content/uploads/2013/11/20131105_5278646e40a39.png" id="tile4" value="4"/>
</div>
<div id="page4">
<h1 align="right">i see</h1>
<div id="pg4ans">
<img src="http://www.iconsfind.com/wp-content/uploads/2013/11/20131105_52786468beae1.png" id="tile5" class="tile2">
<img src="http://www.iconsfind.com/wp-content/uploads/2013/11/20131105_52786462d44f8.png" id="tile6" class="tile2">
<img src="http://www.iconsfind.com/wp-content/uploads/2013/11/20131105_5278645aa8bbc.png" id="tile7" class="tile2">
<img src="http://www.iconsfind.com/wp-content/uploads/2013/11/20131105_52786454d3403.png" id="tile8" class="tile2">
</div>
</div>
有任何线索吗?
答案 0 :(得分:0)
我认为,如果您从Process的InputStream中读取内容,而不是尝试将输出重定向到文件,那么您将获得更多成功。
例如:
//Start the builder and retrieve the created process
Proccess process = pb.start();
BufferedReader br;
String line;
//Get the regular output from the process
br = new BufferedReader(new InputStreamReader(
process.getInputStream()));
while((line = br.readLine()) != null)
{
System.out.println(line);
}
br.close();
您还可以获得任何错误输出:
//Get error output
br = new BufferedReader(new InputStreamReader(
process.getErrorStream()));
while((line = br.readLine()) != null)
{
System.out.println(line);
}
br.close();
这两个InputStream将捕获发送到标准输出或标准错误的任何内容。一旦你捕获它,你可以随心所欲地做任何事情。