2016-05-15 30 views
0

私はJavaからのgnuplotを開くには、このコードを使用しますが、私はgnuplotのへの入力として次のJava文字列を送信する方法がわからない:java文字列をjavaからgnuplotへの入力としてどのように送るのですか?

sp 'F:\DataJava\PDE\EqStringSin.dat' w l 

私のクラス:

public class executeCommand { 
    public static void main(String[] args) { 
    try { 
     ProcessBuilder pb = new ProcessBuilder("wgnuplot"); 
     Process p = pb.start(); // Start the process. 
     p.waitFor(); // Wait for the process to finish. 
     System.out.println("Script executed successfully"); 
    } catch (IOException | InterruptedException e) { 
     e.printStackTrace(); 
    } 
    } 
} 

答えて

0

あなたが取得する必要がありますプロセスからの出力ストリームとそれあなたの入力に書き込み:私はそれをしなかったが、それはうまくいきませんでした

new OutputStreamWriter(p.getOutputStream()).write("sp 'F:\DataJava\PDE\EqStringSin.dat' w l\n"); 
+0

: 'プロセスp = pb.start(); //プロセスを開始します。 \t \t \t新規のOutputStreamWriter(p.getOutputStream())を書き込む( "SP 'F:\\ DataJava \\ PDE \\ EqStringSin.dat W' のL")。 \t \t \t ' –

関連する問題