Get output from a process

后端 未结 5 1393
心在旅途
心在旅途 2020-12-07 05:04

This is a second part to my question here.

I now have a process but I want to know how to get the output from the process?

String filename = matlab.         


        
5条回答
  •  离开以前
    2020-12-07 05:13

    There are a few gotcha's.

    In exec you assume that java is on the path, and the filename should be fully qualified or you should know that the current working dir of the java process is OK.

    main() should return void (nothing). If you want to pass the results out of your program use something like:

    for (Object o : mediaProp) {
       System.out.println(o);
    }
    

    and parse it again on the input stream (the calling software).

    Better yet, include the MediaProperty class in the java path and call main(...) directly in stead of calling a separate java process.

提交回复
热议问题