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