【发布时间】:2014-06-17 10:05:02
【问题描述】:
我想做的是让我自己的java程序通过命令行/终端与pianobarfly(https://github.com/nega0/pianobarfly)交互。此时我似乎可以启动应用程序,但是只有第一行是通过 java 打印出来的。它似乎没有识别下面的线条。我该怎么办?
import java.io.*;
class mainA
{
public static void main (String[] args) throws java.lang.Exception
{
try {
Process p = new ProcessBuilder("/Users/sbuck1994/Desktop/pianobarfly-master/pianobarfly").start();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedWriter output = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
String resultLine = input.readLine();
while (resultLine != null) {
System.out.println(resultLine);
resultLine = input.readLine();
}
int exitVal = p.waitFor();
System.out.println("Exited with error code "+exitVal);
} catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
}
这会导致:
Welcome to pianobarfly (2012.09.07-dev)! Press ? for a list of commands.
当我认为它应该打印这样的内容时:
Welcome to pianobarfly (2012.09.07-dev)! Press ? for a list of commands.
[?] Email:
这是使用终端时的样子: http://i.stack.imgur.com/eQ8vp.png
【问题讨论】: