Created
November 10, 2016 18:52
-
-
Save bsmaat/e54936b5b89aef890bb032d1302bd4f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean downloadWithDeluge(String magnetSite) { | |
String command = "deluge-console add -p /home/billy/deluge-downloads/ " + magnetSite; | |
//String command = "ping -c 4 google.com"; | |
String out = executeCommand(command); | |
System.out.println(out); | |
return false; | |
} | |
private String executeCommand(String command) { | |
StringBuffer output = new StringBuffer(); | |
Process p; | |
try { | |
p = Runtime.getRuntime().exec(new String[]{"bash","-c",command}); | |
p.waitFor(); | |
BufferedReader reader = | |
new BufferedReader(new InputStreamReader(p.getInputStream())); | |
String line = ""; | |
while ((line = reader.readLine())!= null) { | |
output.append(line + "\n"); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
return output.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment