1 |
alfonx |
1328 |
package skrueger.linux; |
2 |
|
|
|
3 |
|
|
import java.io.File; |
4 |
|
|
import java.io.IOException; |
5 |
|
|
|
6 |
|
|
/** |
7 |
|
|
* Utility methods to do linux specific stuff, e.g. symbolic links |
8 |
|
|
*/ |
9 |
|
|
public class LinuxUtil { |
10 |
|
|
|
11 |
|
|
/** |
12 |
|
|
* Creates a symbolic link |
13 |
|
|
* |
14 |
|
|
* @param from |
15 |
|
|
* an existing {@link File} |
16 |
|
|
* @param to |
17 |
|
|
* the new file to create |
18 |
|
|
* @throws IOException |
19 |
|
|
*/ |
20 |
|
|
public static void createSymlink(File from, File to) throws IOException { |
21 |
|
|
ProcessBuilder processBuilder = new ProcessBuilder("/bin/ln", "-s", |
22 |
|
|
from.getAbsolutePath(), to.getAbsolutePath()); |
23 |
|
|
Process started = processBuilder.start(); |
24 |
|
|
try { |
25 |
|
|
started.waitFor(); |
26 |
|
|
} catch (InterruptedException e) { |
27 |
|
|
new RuntimeException(e); |
28 |
|
|
} |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
} |