我想做的是让我自己的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:
以下是使用终端时的情况:https://i.stack.imgur.com/eQ8vp.png
您可能还需要处理错误流。查看此以了解更多信息。