|
@@ -75,7 +75,6 @@ public class Util {
|
|
|
try {
|
|
|
img= ImageIO.read(loadStream(origin, url));
|
|
|
} catch (IOException e) {
|
|
|
- System.err.println("Warning: '" + url + "' loading failed!");
|
|
|
e.printStackTrace();
|
|
|
return defaultImage;
|
|
|
}
|
|
@@ -86,28 +85,23 @@ public class Util {
|
|
|
try {
|
|
|
return ImageIO.read(loadStream(origin, url));
|
|
|
} catch (IOException e) {
|
|
|
- System.err.println("Warning: '" + url + "' loading failed!");
|
|
|
e.printStackTrace();
|
|
|
return defaultImage;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static InputStream loadStream(Object origin, String url){
|
|
|
- System.out.println("Resource loaded!");
|
|
|
InputStream o=origin.getClass().getResourceAsStream(url);
|
|
|
if(o!=null)return o;
|
|
|
else{
|
|
|
- System.out.println("Loading of \""+url+"\" as local resource failed.\nWill attempt to load as File.");
|
|
|
boolean rootSymbol=false; //Whether url starts with a / or \
|
|
|
switch(url.charAt(0)){ //So we can make sure to construct res/path correctly.
|
|
|
case '/':case '\\':rootSymbol=true;
|
|
|
}
|
|
|
try {
|
|
|
- //I am checking, whether the requested File is an internal resource.
|
|
|
- //If it is, res/url has to be used, otherwise url.
|
|
|
//Mixed separators might cause problems. Will fix later.
|
|
|
- File f=new File(url);
|
|
|
- if(!f.exists()/*||!f.getAbsolutePath().equals(url)*/)url="res"+(rootSymbol?"":"/")+url;
|
|
|
+ File f=new File(url);//Possible bug with duplicate names.
|
|
|
+ if(!f.exists())url="res"+(rootSymbol?"":"/")+url;
|
|
|
return new FileInputStream(url);
|
|
|
} catch (FileNotFoundException e1) {
|
|
|
e1.printStackTrace();
|