Examples of URLConnection


Examples of java.net.URLConnection

        final VFSClassLoader loader = createClassLoader();

        final URL resource = loader.getResource("read-tests/file1.txt");

        assertNotNull(resource);
        final URLConnection urlCon = resource.openConnection();
        assertSameURLContent(FILE1_CONTENT, urlCon);
    }
View Full Code Here

Examples of java.net.URLConnection

                                             SSLClientPolicy sslClientPolicy,
                                             String urlStr,
                                             TestHandler handler) {
        try {
            URL url  = new URL(urlStr);
            URLConnection connection = new DummyHttpsConnection(url);
            Configuration configuration = EasyMock.createMock(Configuration.class);
            JettySslClientConfigurer jettySslClientConfigurer =
                new JettySslClientConfigurer(sslClientPolicy,
                                             connection,
                                             configuration);
View Full Code Here

Examples of java.net.URLConnection

                            out = new FileOutputStream(getPathWithoutEscapes(url.getFile()));
                        }
                        // Try to write to some other kind of URI. Some protocols
                        // won't support this, though HTTP should work.
                        else {
                            URLConnection urlCon = url.openConnection();
                            urlCon.setDoInput(false);
                            urlCon.setDoOutput(true);
                            urlCon.setUseCaches(false); // Enable tunneling.
                            if (urlCon instanceof HttpURLConnection) {
                                // The DOM L3 LS CR says if we are writing to an HTTP URI
                                // it is to be done with an HTTP PUT.
                                HttpURLConnection httpCon = (HttpURLConnection) urlCon;
                                httpCon.setRequestMethod("PUT");
                            }
                            out = urlCon.getOutputStream();
                        }
                        ser.setOutputByteStream(out);
                    }
                }
                else {
View Full Code Here

Examples of java.net.URLConnection

                out = new FileOutputStream(getPathWithoutEscapes(url.getFile()));           
            }
            // Try to write to some other kind of URI. Some protocols
            // won't support this, though HTTP should work.
            else {
                URLConnection urlCon = url.openConnection();
                urlCon.setDoInput(false);
                urlCon.setDoOutput(true);
                urlCon.setUseCaches(false); // Enable tunneling.
                if (urlCon instanceof HttpURLConnection) {
                    // The DOM L3 LS CR says if we are writing to an HTTP URI
                    // it is to be done with an HTTP PUT.
                    HttpURLConnection httpCon = (HttpURLConnection) urlCon;
                    httpCon.setRequestMethod("PUT");
                }
                out = urlCon.getOutputStream();
            }
            ser.setOutputByteStream(out);

            if (node.getNodeType() == Node.DOCUMENT_NODE)
                ser.serialize((Document) node);
View Full Code Here

Examples of java.net.URLConnection

          public InputStream run() throws IOException {
        InputStream is = null;
        if (reloadFlag) {
            URL url = classLoader.getResource(resourceName);
            if (url != null) {
          URLConnection connection = url.openConnection();
          if (connection != null) {
              // Disable caches to get fresh data for
              // reloading.
              connection.setUseCaches(false);
              is = connection.getInputStream();
          }
            }
        } else {
            is = classLoader.getResourceAsStream(resourceName);
        }
View Full Code Here

Examples of java.net.URLConnection

      try {
    String resourceName = toResourceName(toBundleName(baseName, locale), format);
    URL url = loader.getResource(resourceName);
    if (url != null) {
        long lastModified = 0;
        URLConnection connection = url.openConnection();
        if (connection != null) {
      // disable caches to get the correct data
      connection.setUseCaches(false);
      if (connection instanceof JarURLConnection) {
          JarEntry ent = ((JarURLConnection)connection).getJarEntry();
          if (ent != null) {
        lastModified = ent.getTime();
        if (lastModified == -1) {
            lastModified = 0;
        }
          }
      } else {
          lastModified = connection.getLastModified();
      }
        }
        result = lastModified >= loadTime;
    }
      } catch (NullPointerException npe) {
View Full Code Here

Examples of java.net.URLConnection

        InputStream is = null;
        BufferedReader br = null;
        try
        {
            // Open the URL and read to our specified line
            URLConnection uc = url.openConnection();
            is = uc.getInputStream();
            br = new BufferedReader(new InputStreamReader(is));

            // Not the most efficient way, but it works
            // (Feel free to patch to seek to the appropriate line)
            for (int i = 1; i <= lineNum; i++)
View Full Code Here

Examples of java.net.URLConnection

  PermissionCollection perms = super.getPermissions(codesource);

  URL url = codesource.getLocation();

  Permission p;
  URLConnection urlConnection;

  try {
      urlConnection = url.openConnection();
      p = urlConnection.getPermission();
  } catch (java.io.IOException ioe) {
      p = null;
      urlConnection = null;
  }
View Full Code Here

Examples of java.net.URLConnection

     * @throws IllegalStateException if the splash screen has already been
     *         closed
     */
    public void setImageURL(URL imageURL) throws NullPointerException, IOException, IllegalStateException {
        checkVisible();
        URLConnection connection = imageURL.openConnection();
        connection.connect();
        int length = connection.getContentLength();
        java.io.InputStream stream = connection.getInputStream();
        byte[] buf = new byte[length];
        int off = 0;
        while(true) {
            // check for available data
            int available = stream.available();
View Full Code Here

Examples of java.net.URLConnection

            if (url == null) {
                throw new IllegalStateException("No resource named '" + library + "' was found in the current classloader.");
            }

            // got url, open it
            URLConnection urlConnection = null;
            try {
                urlConnection = url.openConnection();
            } catch (IOException e) {
                throw new IllegalStateException("Cannot open connection on the URL '" + url + "'.", e);
            }
            urlConnection.setDefaultUseCaches(false);

            Reader reader = null;
            try {
                try {
                    reader = new InputStreamReader(urlConnection.getInputStream());
                } catch (IOException e) {
                    throw new IllegalStateException("Cannot get inputstream on the URL '" + url + "'.", e);
                }
                BufferedReader bufferedReader = new BufferedReader(reader);
                String fileName = null;
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.