protected void parseXml() throws Exception { InputSource xmlSource = new InputSource( ResourceLoader.getResourceAsStream( GroupServiceConfiguration.class, SERVICES_XML)); if (xmlSource != null) { XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); reader.setContentHandler(serviceHandler); reader.parse(xmlSource); } } }
protected void parseXml() throws Exception { InputSource xmlSource = new InputSource( ResourceLoader.getResourceAsStream( GroupServiceConfiguration.class, SERVICES_XML)); if (xmlSource != null) { XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); reader.setContentHandler(serviceHandler); reader.parse(xmlSource); } } }
/** * Get the contents of a URL as a java.util.Properties object * * @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 whose contents to * load * @return the actual contents of the resource as a Properties object * @throws ResourceMissingException * @throws java.io.IOException */ public static Properties getResourceAsProperties(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { InputStream inputStream = null; Properties props = null; try { inputStream = getResourceAsStream(requestingClass, resource); props = new Properties(); props.load(inputStream); } finally { if (inputStream != null) inputStream.close(); } return props; }
/** * Get the contents of a URL as a java.util.Properties object * * @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 whose contents to * load * @return the actual contents of the resource as a Properties object * @throws ResourceMissingException * @throws java.io.IOException */ public static Properties getResourceAsProperties(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { InputStream inputStream = null; Properties props = null; try { inputStream = getResourceAsStream(requestingClass, resource); props = new Properties(); props.load(inputStream); } finally { if (inputStream != null) inputStream.close(); } return props; }
/** * Get the contents of a URL as a 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 whose contents to * load * @return the actual contents of the resource as a String * @throws ResourceMissingException * @throws java.io.IOException */ public static String getResourceAsString(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { String line = null; BufferedReader in = null; StringBuffer sbText = null; try { in = new BufferedReader( new InputStreamReader( getResourceAsStream(requestingClass, resource), UTF_8)); sbText = new StringBuffer(1024); while ((line = in.readLine()) != null) sbText.append(line).append("\n"); } finally { if (in != null) in.close(); } return sbText.toString(); } }
/** * Get the contents of a URL as a 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 whose contents to * load * @return the actual contents of the resource as a String * @throws ResourceMissingException * @throws java.io.IOException */ public static String getResourceAsString(Class<?> requestingClass, String resource) throws ResourceMissingException, IOException { String line = null; BufferedReader in = null; StringBuffer sbText = null; try { in = new BufferedReader( new InputStreamReader( getResourceAsStream(requestingClass, resource), UTF_8)); sbText = new StringBuffer(1024); while ((line = in.readLine()) != null) sbText.append(line).append("\n"); } finally { if (in != null) in.close(); } return sbText.toString(); } }
factoryToUse = ResourceLoader.nonValidatingDocumentBuilderFactory; inputStream = getResourceAsStream(requestingClass, resource); DocumentBuilder db = factoryToUse.newDocumentBuilder();
factoryToUse = ResourceLoader.nonValidatingDocumentBuilderFactory; inputStream = getResourceAsStream(requestingClass, resource); DocumentBuilder db = factoryToUse.newDocumentBuilder();