code: public static File getResourceAsFile(String resource) {
          ClassLoader cl = Thread.currentThread().getContextClassLoader();
          try {
              return new File(URLDecoder.decode(cl.getResource(resource)
                      .getFile(), "UTF-8"));
          } catch (UnsupportedEncodingException uee) {
              return null;
          }
      }
docs: Loads a file into memory from the classpath