Package java.net

Examples of java.net.URL.openConnection()


  sUsr = sUser;
  sPwd = sPassword;

  URL oUrl = new URL(sUrl);
    oCon = (HttpURLConnection) oUrl.openConnection();
    oCon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    oCon.setDoOutput(true);
    oCon.setDoInput (true);
    oCon.setUseCaches(false);
  oCon.setRequestMethod("POST");
View Full Code Here


    if (DebugFile.trace) {
      DebugFile.writeln("new URL("+sUrl+"username="+sUsr+"&password=..."+sFrm+"&to="+sMsisdn+"&text=...)");
    }

    URL oUrl = new URL(sQry);
      HttpURLConnection oCon = (HttpURLConnection) oUrl.openConnection();
      int iStatusCode = oCon.getResponseCode();

    if (DebugFile.trace) {
      DebugFile.writeln("response code is "+String.valueOf(iStatusCode));
    }
View Full Code Here

      } // next
    } // fi (aFiles)
  } else if (sSourceURI.startsWith("http://")) {
    try {
        URL oUrl = new URL(sSourceURI);
      HttpURLConnection oCon = (HttpURLConnection) oUrl.openConnection();
      int iResponseCode = oCon.getResponseCode();
      oCon.disconnect();
      bExists = (iResponseCode>=200 && iResponseCode<=299);
      } catch (MalformedURLException mue) {
        throw new IOException(mue.getMessage());
View Full Code Here

        throw new IOException(mue.getMessage());
      }
  } else if (sSourceURI.startsWith("https://")) {
    try {
        URL oUrl = new URL(sSourceURI);
      HttpsURLConnection oCon = (HttpsURLConnection) oUrl.openConnection();
      int iResponseCode = oCon.getResponseCode();
      oCon.disconnect();
      bExists = (iResponseCode>=200 && iResponseCode<=299);
      } catch (MalformedURLException mue) {
        throw new IOException(mue.getMessage());
View Full Code Here

        final VFSClassLoader loader = createClassLoader();

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

        assertNotNull(resource);
        final URLConnection urlCon = resource.openConnection();
        assertSameURLContent(FILE1_CONTENT, urlCon);
    }

    /**
     * Tests package sealing.
View Full Code Here

    } catch (MalformedURLException e) {
      throw new IOException("** MalformedURLException on URL <" + urlString + ">\n" + e.getMessage() + "\n");
    }

    try {
      java.net.HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
        // check response code is good
        int responseCode = httpConnection.getResponseCode();
        System.out.println(" response code= "+responseCode);
        if (responseCode / 100 != 2)
          throw new IOException("** Cant open URL <" + urlString + ">\n Response code = " + responseCode
View Full Code Here

    } catch (MalformedURLException e) {
      throw new IOException( "** MalformedURLException on URL <"+urlString+">\n"+e.getMessage()+"\n");
    }

    try {
      java.net.URLConnection connection = url.openConnection();

      if (connection instanceof HttpURLConnection) {
        java.net.HttpURLConnection httpConnection = (HttpURLConnection) connection;
        // check response code is good
        int responseCode = httpConnection.getResponseCode();
View Full Code Here

                            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
View Full Code Here

                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
View Full Code Here

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