Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Image loadImage(String name)
- {
- Image result = cache.get(name);
- if (result == null)
- {
- try
- {
- result = ImageIO.read(new File("res/images/" + name));
- }
- catch (IOException e1)
- {
- try
- {
- InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("res/images/" + name);
- if (is == null)
- {
- throw new IOException();
- }
- result = ImageIO.read(is);
- }
- catch (IOException e2)
- {
- System.err.println("Failed to load image: " + name);
- }
- }
- if (result == null)
- {
- result = imageNotFound;
- }
- }
- cache.put(name, result);
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement