i have a .jar file, which I can run on the command line:
java -jar myFile.jar argument1
I want to save the output of this .jar as a String vari
If you can't include the other jar,
you can use something like that
Runtime re = Runtime.getRuntime();
BufferedReader output;
try{
cmd = re.exec("java -jar MyFile.jar" + argument);
output = new BufferedReader(new InputStreamReader(cmd.getInputStream()));
} catch (IOException ioe){
ioe.printStackTrace();
}
String resultOutput = output.readLine();
I know my code isn't perfect like the catching exception, etc but I think this could give you a good idea.