我正在嘗試使用我的 Java 代碼運行二進制文件,但它給我的結(jié)果與我自己從終端運行它時不同。Java代碼:Runtime rt = Runtime.getRuntime();String path = System.getProperty("user.dir") + "/src/main/go/Sentiment";String command = path + " " + "\"i love this\"";System.out.println(command);Process p = rt.exec(command);Scanner s = new Scanner(p.getInputStream()).useDelimiter("\\A");String output = s.hasNext() ? s.next() : "";System.out.println(output);這打?。?home/ninesalt/repositories/elasticsearch-ingest-opennlp/src/main/go/Sentiment “我喜歡這個”0但是,當(dāng)我在終端中運行相同的命令時,我會得到 1 。為什么會這樣?
Java 運行時二進制顯示不同的結(jié)果
慕無忌1623718
2022-05-21 16:38:21