import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class octave {
public static void main(String[] args) {
Runtime r = Runtime.getRuntime();
try {
String name = "toto.png"; // input filename
// output_name = testimagefun(input_name)
String[] cmd = {"octave","--eval","output_name = testimagefun('" + name + "')"};
Process p = r.exec(cmd);
p.waitFor();
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = b.readLine()) != null) {
//System.out.println(line);
if (line.startsWith("output_name")) {
System.out.println("result is in " + line.split("=")[1]);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}