4
我想在Java程序中运行groff
。输入来自一个字符串。在实际的命令行中,我们将在Linux/Mac中终止输入^D
。那么如何在Java程序中发送这个终止符?如何将EOF发送到Java中的进程?
String usage +=
".Dd \\[year]\n"+
".Dt test 1\n"+
".Os\n"+
".Sh test\n"+
"^D\n"; // <--- EOF here?
Process groff = Runtime.getRuntime().exec("groff -mandoc -T ascii -");
groff.getOutputStream().write(usage.getBytes());
byte[] buffer = new byte[1024];
groff.getInputStream().read(buffer);
String s = new String(buffer);
System.out.println(s);
还是其他想法?
你能用http://stackoverflow.com/q/43051640/2674303帮助吗? – gstackoverflow