Package java.net

Examples of java.net.URL.openConnection()


        return url.openConnection();
    }

    public static URLConnection httpPost(WebServer webServer, String path, String body) throws IOException {
        URL url = new URL(webServer.getUri().toURL(), path);
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("POST");
        urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        urlConnection.setDoOutput(true);
        urlConnection.getOutputStream().write(body.getBytes(Charset.forName("UTF8")));
        return urlConnection;
View Full Code Here


  public boolean exists() {
  if (pathUrlConnection == null)
  try {
    URL u = new URL(path);
    pathUrlConnection = u.openConnection();
  } catch (MalformedURLException e) {
  } catch (IOException e) {
  }
  if ( pathUrlConnection != null )
  try {
View Full Code Here

      return (0);
    if (pathUrlConnection == null)
    {
      try {
          URL u = new URL(path);
          pathUrlConnection = u.openConnection();
      } catch (MalformedURLException e) {
      } catch (IOException e) {
      }
    }
    if (pathUrlConnection != null)
View Full Code Here

  public Date lastModified() {
    if (pathUrlConnection == null)
    {
      try {
        URL u = new URL(path);
        pathUrlConnection = u.openConnection();
      } catch (MalformedURLException e) {
      } catch (IOException e) {
      }
    }
View Full Code Here

            }
            try
            {
                // - Get around the fact the URL won't be released until the JVM
                //   has been terminated, when using the 'jar' uri protocol.
                url.openConnection().setDefaultUseCaches(false);
            }
            catch (final IOException exception)
            {
                // - ignore the exception
            }
View Full Code Here

                        }
                    }

                } else {

                    URLConnection uc = repositoryURL.openConnection();
                    if (uc instanceof JarURLConnection){
                        JarFile  jarFile = ((JarURLConnection)uc).getJarFile();

                        // get all jar entries that belongs to the help repository
                        Set jarEntries = getJarDirectoryEntries(jarFile, ((JarURLConnection) uc).getEntryName());
View Full Code Here

        }
         
      }
     
      URL url = new URL(connect_address);
      HttpURLConnection httpConnection =(HttpURLConnection) url.openConnection();
     
      httpConnection.setRequestProperty("User-Agent",     JMUpdater.USER_AGENT);
      httpConnection.setRequestProperty("Accept-Charset", JMUpdater.ENCODING);
     
      httpConnection.setDoInput(true);
View Full Code Here

   private HttpURLConnection conn;
  
   public UrlConnection(String urlString) throws Exception {
      URL url = new URL(urlString);
      this.conn = (HttpURLConnection)url.openConnection();
      this.conn.setDoOutput(true);
   }

   public InputStream getInputStream() throws IOException {
      return this.conn.getInputStream();
View Full Code Here

   {
      StringBuffer ret = null;
      try {
         // connect to the server
         URL url = new URL(urlStr);
         HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();

         // send a POST
         urlConnection.setRequestMethod("POST");
         urlConnection.setDoOutput(true);
         OutputStream outStream = urlConnection.getOutputStream();
View Full Code Here

   
    URL url = new URL("http://www.amazon.de/");
    System.setProperty("http.proxyHost", "localhost");
    System.setProperty("http.proxyPort", Integer.toString(proxy.getLocalPort()));

    URLConnection con =  url.openConnection();

     
      con.setRequestProperty("Proxy-Authorization",
                         "Basic " + new String(Base64.encodeBase64(("test:test").getBytes())));
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.