/** * Returns the requested resource as a URL string. * * @param requestingClass the java.lang.Class object of the class that is attempting to load the * resource * @param resource a String describing the full or partial URL of the resource to load * @return the requested resource as a URL string * @throws ResourceMissingException */ public static String getResourceAsURLString(Class<?> requestingClass, String resource) throws ResourceMissingException { return getResourceAsURL(requestingClass, resource).toString(); }
/** * Returns the requested resource as a URL string. * * @param requestingClass the java.lang.Class object of the class that is attempting to load the * resource * @param resource a String describing the full or partial URL of the resource to load * @return the requested resource as a URL string * @throws ResourceMissingException */ public static String getResourceAsURLString(Class<?> requestingClass, String resource) throws ResourceMissingException { return getResourceAsURL(requestingClass, resource).toString(); }
/** * Returns the requested resource as a stream. * * @param requestingClass the java.lang.Class object of the class that is attempting to load the * resource * @param resource a String describing the full or partial URL of the resource to load * @return the requested resource as a stream * @throws ResourceMissingException * @throws java.io.IOException */ public static InputStream getResourceAsStream(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { return getResourceAsURL(requestingClass, resource).openStream(); }
/** * Returns the requested resource as a stream. * * @param requestingClass the java.lang.Class object of the class that is attempting to load the * resource * @param resource a String describing the full or partial URL of the resource to load * @return the requested resource as a stream * @throws ResourceMissingException * @throws java.io.IOException */ public static InputStream getResourceAsStream(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { return getResourceAsURL(requestingClass, resource).openStream(); }
/** * Returns the requested resource as a SAX input source. * * @param requestingClass the java.lang.Class object of the class that is attempting to load the * resource * @param resource a String describing the full or partial URL of the resource to load * @return the requested resource as a SAX input source * @throws ResourceMissingException * @throws java.io.IOException */ public static InputSource getResourceAsSAXInputSource(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { URL url = getResourceAsURL(requestingClass, resource); InputSource source = new InputSource(url.openStream()); source.setPublicId(url.toExternalForm()); return source; }
public static long getResourceLastModified(Class<?> requestingClass, String resource) { final URL contentUrl = getResourceAsURL(requestingClass, resource); final String contentFileName = contentUrl.getFile(); // Use JAR modified time if the resource is in a .jar file denoted by ! delimeter final int delimIndex = contentFileName.indexOf('!'); final File contentFile; if (delimIndex > 0) { contentFile = new File(contentFileName.substring(0, delimIndex)); } else { contentFile = new File(contentFileName); } return contentFile.lastModified(); }
public static long getResourceLastModified(Class<?> requestingClass, String resource) { final URL contentUrl = getResourceAsURL(requestingClass, resource); final String contentFileName = contentUrl.getFile(); // Use JAR modified time if the resource is in a .jar file denoted by ! delimeter final int delimIndex = contentFileName.indexOf('!'); final File contentFile; if (delimIndex > 0) { contentFile = new File(contentFileName.substring(0, delimIndex)); } else { contentFile = new File(contentFileName); } return contentFile.lastModified(); }
/** * Returns the requested resource as a SAX input source. * * @param requestingClass the java.lang.Class object of the class that is attempting to load the * resource * @param resource a String describing the full or partial URL of the resource to load * @return the requested resource as a SAX input source * @throws ResourceMissingException * @throws java.io.IOException */ public static InputSource getResourceAsSAXInputSource(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { URL url = getResourceAsURL(requestingClass, resource); InputSource source = new InputSource(url.openStream()); source.setPublicId(url.toExternalForm()); return source; }