Examples of openStream()


Examples of java.net.URL.openStream()

          @WebParam(name = "albumUrl", partName = "albumUrl")
          String albumUrl) {
    try {
      URL       albumURL   = new URL(albumUrl);
      Unmarshaller   um       = context.createUnmarshaller();
      FeedType ob = um.unmarshal(new StreamSource(albumURL.openStream()),FeedType.class).getValue();
      return ob;
    } catch (Exception e) {
      e.printStackTrace();
      throw new Error("Album request failed",e);
    }

Examples of java.net.URL.openStream()

    Properties props = new Properties();
    InputStream inputStream = null;
    try {
      log.info("Reading Dozer properties from URL [{}]", url);
      inputStream = url.openStream();
      props.load(inputStream);
    } catch (IOException e) {
      MappingUtils.throwMappingException("Problem loading Dozer properties from URL [" + propFileName + "]", e);
    } finally {
      if (inputStream != null) {

Examples of java.net.URL.openStream()

      String fileName = systemId.substring(systemId.indexOf(DozerConstants.XSD_NAME));
      log.debug("Trying to locate [{}] in classpath", fileName);
      try {
        DozerClassLoader classLoader = BeanContainer.getInstance().getClassLoader();
        URL url = classLoader.loadResource(fileName);
        InputStream stream = url.openStream();
        InputSource source = new InputSource(stream);
        source.setPublicId(publicId);
        source.setSystemId(systemId);
        log.debug("Found beanmapping XML Schema [{}] in classpath", systemId);
        return source;

Examples of java.net.URL.openStream()

      } else {
        allPath += "&nocache=true";
      }
      URL url = new URL(allPath);
      BufferedReader reader =
        new BufferedReader(new InputStreamReader(url.openStream()));
      String content = "<!-- �ON smart cache for url : " + path + " -->";
      String line = "";
      while (line != null) {
        line = reader.readLine();
        if (line != null) {

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");

Examples of java.net.URL.openStream()

    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{

Examples of java.net.URL.openStream()

  @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:"

Examples of java.net.URL.openStream()

      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 {

Examples of java.net.URL.openStream()

        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,

Examples of java.net.URL.openStream()

      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);
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.