source: AE/installer2/src/net/oni2/aeinstaller/backend/AppExecution.java@ 654

Last change on this file since 654 was 623, checked in by alloc, 12 years ago

AEI2 0.83:

  • Dependencies from Mods to Tools supported
  • Installed tools can get a menu entry to launch them
  • Mods can unlock levels in persist.dat through UnlockLevel-tag
File size: 1.4 KB
Line 
1package net.oni2.aeinstaller.backend;
2
3import java.io.BufferedReader;
4import java.io.File;
5import java.io.IOException;
6import java.io.InputStream;
7import java.io.InputStreamReader;
8import java.util.List;
9import java.util.Vector;
10
11/**
12 * @author Christian Illy
13 */
14public class AppExecution {
15
16 /**
17 * Execute a short running application and wait for termination
18 *
19 * @param cmdLine
20 * List of command and arguments
21 * @return List of output lines
22 * @throws IOException
23 * Exc
24 */
25 public static Vector<String> executeAndWait(List<String> cmdLine)
26 throws IOException {
27 ProcessBuilder pb = new ProcessBuilder(cmdLine);
28 pb.redirectErrorStream(true);
29 Process proc = pb.start();
30
31 InputStream is = proc.getInputStream();
32 InputStreamReader isr = new InputStreamReader(is);
33 BufferedReader br = new BufferedReader(isr);
34
35 String line;
36 Vector<String> lines = new Vector<String>();
37
38 while ((line = br.readLine()) != null) {
39 lines.add(line);
40 }
41 return lines;
42 }
43
44 /**
45 * Execute an app without waiting
46 *
47 * @param cmd
48 * Command and parameters
49 * @param workingDirectory
50 * Working directory of app
51 */
52 public static void execute(List<String> cmd, File workingDirectory) {
53 try {
54 ProcessBuilder pb = new ProcessBuilder(cmd);
55 pb.directory(workingDirectory);
56 pb.start();
57 } catch (IOException e) {
58 e.printStackTrace();
59 }
60 }
61
62}
Note: See TracBrowser for help on using the repository browser.