[java-decompiler] common file comparison method extracted; test data updated

This commit is contained in:
Roman Shevchenko
2015-09-07 19:23:12 +03:00
parent 9a06c52a8f
commit aab87019ef
6 changed files with 82 additions and 48 deletions

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Created-By: 1.8.0_20 (Oracle Corporation)

View File

@@ -0,0 +1,11 @@
package pkg;
import pkg.res.Loader;
public class Main {
public static void main(String[] args) {
Loader loader = new Loader();
String resource = loader.getResource();
System.out.println(resource);
}
}

View File

@@ -0,0 +1,25 @@
package pkg.res;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
public class Loader {
public String getResource() {
URL resource = this.getClass().getClassLoader().getResource("pkg/res/resource.txt");
if(resource == null) {
throw new RuntimeException("Resource missing");
} else {
try {
File e = new File(resource.toURI());
byte[] bytes = new byte[(int)e.length()];
FileInputStream stream = new FileInputStream(e);
stream.read(bytes);
stream.close();
return new String(bytes, "UTF-8");
} catch (Exception var5) {
throw new RuntimeException("Resource load failed", var5);
}
}
}
}