我要做的是让我自己的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