3

这是用于将文件添加到队列的 unix 命令。

enq -P QueueName:PrinterName FileName

是否可以使用 java.lang. 运行上述命令?

4

2 回答 2

4

是的,可以使用ProcessBuilder

ProcessBuilder builder = 
           new ProcessBuilder("enq", "-P", "QueueName", "FileName");
Process process = builder.start();
InputStreamReader streamReader = new InputStreamReader(process.getInputStream());
BufferedReader reader = new BufferedReader(streamReader);
String line;
while ((line = reader.readLine()) != null) {
   System.out.println(line);
}

请参阅:enq 语法

于 2013-05-06T13:38:05.300 回答
0
Process p = Runtime.getRuntime().exec(new String[]{"enq", "-P", "QueueName:PrinterName FileName"});
于 2013-05-06T13:40:26.923 回答