Get output from a process

后端 未结 5 1394
心在旅途
心在旅途 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

    First, you should use:

    "java -cp . mediaProperty " + filename
    

    for calling the java process. The "-cp ." defines the classpath and I have made the assumption that the java file is compiled and the generated class file is at the same path as the executing process.

    Then, you need to print the result at the standard output and not just return it. Finally, read this article for reading the output.

    • Tip 1: Rename the class to MediaProperty
    • Tip 2: Why you don't call the MediaProperty class directly from your code? Is it necessary to start a new process?

提交回复
热议问题