1 package de.lathanda.eos.base;
 
    3 import static java.awt.image.BufferedImage.TYPE_INT_RGB;
 
    5 import java.awt.image.BufferedImage;
 
    6 import java.io.BufferedReader;
 
    8 import java.io.FileInputStream;
 
    9 import java.io.FileNotFoundException;
 
   10 import java.io.IOException;
 
   11 import java.io.InputStream;
 
   12 import java.io.InputStreamReader;
 
   14 import javax.imageio.ImageIO;
 
   15 import javax.swing.ImageIcon;
 
   26     private static String workingDirectory;
 
   34             return ImageIO.read(in);
 
   35         } 
catch (IOException ioe) {
 
   36             return createErrorImage(ioe);
 
   46             return ImageIO.read(in);
 
   47         } 
catch (IOException ioe) {
 
   48             return createErrorImage(ioe);
 
   57         if (workingDirectory.endsWith(
"/")) {
 
   76     private static BufferedImage createErrorImage(Exception e) {
 
   77         BufferedImage err = 
new BufferedImage(256, 256, TYPE_INT_RGB);
 
   78         err.createGraphics().drawString(e.getLocalizedMessage(), 5, 30);
 
   92         InputStream is = 
null;
 
   96             is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
 
  104             is = ClassLoader.getSystemResourceAsStream(filename);
 
  109                 is = 
new FileInputStream(filename);
 
  110             } 
catch (FileNotFoundException fnfe) {
 
  116             throw new FileNotFoundException(filename);
 
  129         InputStream is = 
null;
 
  132             is = 
new FileInputStream(workingDirectory + filename);
 
  133         } 
catch (FileNotFoundException fnfe) {
 
  139                 is = 
new FileInputStream(filename);
 
  140             } 
catch (FileNotFoundException fnfe) {
 
  146             throw new FileNotFoundException(filename);
 
  159     public static InputStream 
getConfigFileAsStream(String subdirectory, String filename) 
throws FileNotFoundException {
 
  160         InputStream is = 
null;
 
  162         String home = System.getProperty(
"user.home");
 
  163         File file = 
new File(home + 
"/"+subdirectory+
"/"+filename);
 
  165             is = 
new FileInputStream(file);
 
  166         } 
catch (FileNotFoundException fnfe) {
 
  172                 is = 
new FileInputStream(filename);
 
  173             } 
catch (FileNotFoundException fnfe) {
 
  179             is = ClassLoader.getSystemResourceAsStream(filename);
 
  183             throw new FileNotFoundException(filename);
 
  200         } 
catch (IOException ioe) {
 
static BufferedReader getResourceAsReader(String filename)
 
static InputStream getConfigFileAsStream(String subdirectory, String filename)
 
static void closeQuietly(InputStream input)
 
static ImageIcon loadResourceIcon(String name)
 
static BufferedImage loadResourceImage(String name)
 
static InputStream getResourceAsStream(String filename)
 
static InputStream getLocalFileAsStream(String filename)
 
static BufferedImage loadLocalImage(String name)
 
static void setWorkingDirectory(String workingDirectory)