Created
April 23, 2013 21:00
-
-
Save finsterthecat/5447349 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package ca.ontario.moh.stix.loadfile; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
/** | |
* Decrypt file using 7zip | |
* | |
*/ | |
public class App { | |
public static void main(String[] args) throws IOException, InterruptedException { | |
if (args.length != 2) throw new IllegalArgumentException("usage: program file password"); | |
Runtime r = Runtime.getRuntime(); | |
Process p = r.exec("\"c:\\Program Files\\7-Zip\\7z.exe\" x -so " + args[0] + " -p" + args[1]); | |
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream())); | |
BufferedReader e = new BufferedReader(new InputStreamReader(p.getErrorStream())); | |
String line; | |
System.out.println("\n\nFile Contents:\n"); | |
while ((line = b.readLine()) != null) { | |
System.out.println(line); | |
} | |
System.out.println("\n\nErrors:\n"); | |
while ((line = e.readLine()) != null) { | |
System.out.println(line); | |
} | |
p.waitFor(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK, checked out winzipaes and ran the tests successfully. Going with that as superior solution. This is still decent example for executing runtime and capturing sysout, syserr in a java program should I ever feel the need.