diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginTemplate.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginTemplate.java index 783cde2b..ec67bb18 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginTemplate.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginTemplate.java @@ -4,6 +4,7 @@ import java.io.IOException; import org.apache.commons.io.FilenameUtils; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.resources.IconResources; +import the.bytecode.club.bytecodeviewer.resources.Resource; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -46,7 +47,7 @@ public enum PluginTemplate public String getContents() throws IOException { if(contents == null) - contents = IconResources.loadResourceAsString(resourcePath); + contents = Resource.loadResourceAsString(resourcePath); return contents; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java index c3f76a63..ef571150 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java @@ -112,15 +112,6 @@ public class IconResources } } - public static String loadResourceAsString(String resourcePath) throws IOException - { - try (InputStream is = IconResources.class.getResourceAsStream(resourcePath)) { - if (is == null) - return null; - return IOUtils.toString(is, StandardCharsets.UTF_8); - } - } - public static BufferedImage resize(BufferedImage image, int width, int height) { return Scalr.resize(image, Scalr.Method.ULTRA_QUALITY, width, height); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/Resource.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/Resource.java index f36035e7..6b7a2a45 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/Resource.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/Resource.java @@ -1,7 +1,12 @@ package the.bytecode.club.bytecodeviewer.resources; +import org.apache.commons.io.IOUtils; import org.objectweb.asm.tree.ClassNode; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -36,6 +41,15 @@ public class Resource this.workingName = workingName; this.container = container; } + + public static String loadResourceAsString(String resourcePath) throws IOException + { + try (InputStream is = IconResources.class.getResourceAsStream(resourcePath)) { + if (is == null) + return null; + return IOUtils.toString(is, StandardCharsets.UTF_8); + } + } /** * Returns the resource bytes from the resource container diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java index a240d5e3..03ee1035 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java @@ -14,6 +14,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.api.BCV; import the.bytecode.club.bytecodeviewer.resources.IconResources; +import the.bytecode.club.bytecodeviewer.resources.Resource; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -158,7 +159,7 @@ public enum Language if(translationMap == null) { translationMap = BytecodeViewer.gson.fromJson( - IconResources.loadResourceAsString(resourcePath), + Resource.loadResourceAsString(resourcePath), new TypeToken>() {}.getType()); } @@ -178,7 +179,7 @@ public enum Language return; LinkedMap translationMap = BytecodeViewer.gson.fromJson( - IconResources.loadResourceAsString(resourcePath), + Resource.loadResourceAsString(resourcePath), new TypeToken>(){}.getType()); Set existingKeys = new HashSet<>();