package api;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Exec {
/**
* @param args
*/
public static void main(String[] args) {
String result = "";
try {
// Execute command
String command = "k:\\curl.exe -d login_name=mohwtest -d login_passwd=12345 --insecure https://mohw.cyberhood.net.tw/xml_import.php";
Process child = Runtime.getRuntime().exec(command);
DataInputStream in = new DataInputStream(
child.getInputStream());
BufferedReader br = new BufferedReader(
new InputStreamReader(in));
String line;
while ((line = br.readLine()) != null) {
result +=line;
}
in.close();
} catch (IOException e) {
}
System.out.println(result);
}
}
Created
September 11, 2015 09:24
-
-
Save philipz/f3348e7843994bdd56f0 to your computer and use it in GitHub Desktop.
Java Runtime.getRuntime().exec() Example
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment