Package java.net

Examples of java.net.URL.openStream()


      }
      if (url == null) {
        System.out.println("No properties file: " + propertyName + " found");
      } else {
        Properties bundle = new Properties();
        InputStream is = url.openStream();
        if (is != null) {
          bundle.load(is);
          is.close();
        } else {
          throw new IOException("Properties file " + propertyName  + " not available");
View Full Code Here


    String resourceName = "file:" + temp.getAbsolutePath();
    URL url = loader.getResource(resourceName);
    assertNotNull("URL should not be null", url);

    InputStream is = url.openStream();
    assertNotNull("input stream should not be null", is);
  }

  @Test(expected = MappingException.class)
  public void testGetResouce_MalformedUrl() throws Exception{
View Full Code Here

  @Test(expected = IOException.class)
  public void testGetResource_FileOutsideOfClasspath_NotFound() throws Exception {
    URL url = loader.getResource("file:" + System.currentTimeMillis());
    assertNotNull("URL should not be null", url);
    url.openStream();
  }

  @Test
  public void testGetResource_FileOutsideOfClasspath_InvalidFormat() throws Exception {
    // when using a file outside of classpath the file name must be prepended with "file:"
View Full Code Here

      MappingUtils.throwMappingException("Unable to locate dozer mapping file [" + fileName + "] in the classpath!");
    }

    InputStream stream = null;
    try {
      stream = url.openStream();
    } catch (IOException e) {
      MappingUtils.throwMappingException("Unable to open URL input stream for dozer mapping file [" + url + "]");
    } finally {
      if (stream != null) {
        try {
View Full Code Here

        if (paths.add(fpath)) {
            try {
               
                // access the included binding as input stream
                UnmarshallingContext ictx = new UnmarshallingContext();
                ictx.setDocument(url.openStream(), null);
               
                // get basic name and package information from binding
                ictx.parseToStartTag(URI_ELEMENTS, BINDING_ELEMENT);
                String fname = org.jibx.binding.Utility.fileName(path);
                String name = ictx.attributeText(URI_ATTRIBUTES, BINDING_NAME,
View Full Code Here

      private boolean isDownloadWorking(String pathToFile, String textToFind)
      {
         try
         {
            URL downloadUrl = new URL("http://localhost:8080" + pathToFile);
            BufferedReader r = new BufferedReader(new InputStreamReader(downloadUrl.openStream()));
            String str;
            StringBuffer sb = new StringBuffer();
            while ((str = r.readLine()) != null)
            {
               sb.append(str);
View Full Code Here

      URL configFile =
        SimpleCommandSet.class.getResource("/org/quickserver/net/qsadmin/gui/conf/MainCommandPanel.xml");
      if(configFile==null)
        throw new RuntimeException("XML File not found : "+"MainCommandPanel.xml");

      InputStream input = configFile.openStream();
      logger.fine("Loading command config from xml file : " + input);
      sms = (SimpleCommandSet) digester.parse(input);     
    } catch(Exception e) {
      logger.severe("Could not init from xml file : " +e);
      logger.fine("StackTrace:\n"+MyString.getStackTrace(e));
View Full Code Here

      URL configFile =
        PropertieSet.class.getResource("/org/quickserver/net/qsadmin/gui/conf/PropertieSet.xml");
      if(configFile==null)
        throw new RuntimeException("XML File not found : "+"PropertieSet.xml");

      InputStream input = configFile.openStream();     
      logger.fine("Loading command config from xml file : " + input);
      ps = (PropertieSet) digester.parse(input);     
    } catch(Exception e) {
      logger.severe("Could not init from xml file : " +e);
      logger.fine("StackTrace:\n"+MyString.getStackTrace(e));
View Full Code Here

   * Add a language file to the internationalization database
   */
  public static void addLanguageFile(String prefix) throws GUIException {
    try {
      URL url = InternationalizationManager.class.getResource("/" + prefix + "." + Locale.getDefault().toString() + ".properties");
      properties.load(url.openStream());
    } catch (Exception e) {
      throw new GUIException("Error while loading internationalization property file", e);
    }
  }

View Full Code Here

  public static void initializeLogging() throws GUIException {
    try {
     
      URL url = GUIUtils.class.getResource("/resources/xmlgui/log4j.properties");
      Properties properties = new Properties();
      properties.load(url.openStream());
      PropertyConfigurator.configure(properties);
    } catch (Exception e) {
      throw new GUIException("Error while initializing logging", e);
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.