Package java.net

Examples of java.net.URLConnection


    } catch ( MalformedURLException e ) {
      throw new FreedbException("The URL: "+url+" is invalid, correct the server setting");
    }
    assert url != null;

    URLConnection connection = null;

    try {
      connection = url.openConnection();
      setupProxy(connection);
      connection.setDoOutput( true );

      PrintWriter out = new PrintWriter(connection.getOutputStream() );
            // System.out.println( "cmd=" + servercommand + "&hello=" + clientLogin + "+" + clientDomain + "+" + softwareName + "+" + softwareVersion + "&proto=6");
            out.println( "cmd=" + command + "&hello=" + this.settings.getUserLogin() + "+" + this.settings.getUserDomain() + "+" + this.settings.getClientName() + "+" + this.settings.getClientVersion() + "&proto="+ this.settings.getProtocol() );
            out.close();
    } catch ( IOException e ) {
      //e.printStackTrace();
      throw new FreedbException( "Error while trying to connect to freedb server, "+e.getMessage()+". Check your internet connection settings." );
    }
    assert connection != null;

    String output = null;

    try {
      InputStreamReader isr;
     
      try {
        isr = new InputStreamReader( connection.getInputStream(), "UTF-8" );
      } catch( UnsupportedEncodingException ex) {
        isr = new InputStreamReader( connection.getInputStream() );
      }
     
      BufferedReader in = new BufferedReader( isr );
      String inputLine;
View Full Code Here


       URL file = new URL(applicationStoreProtocol, applicationStoreHost, applicationStorePort, "/getExtensionDescriptor.do" //$NON-NLS-1$
             + parms);
         if (events != null)
             events.debug(MessageFormat.format(Messages.getString("VPNLauncher.requestApplicationUsing"), new Object[] { file.toExternalForm() })); //$NON-NLS-1$

         URLConnection con = (URLConnection)file.openConnection();
         con.setUseCaches(false);

         try {
             Method m = con.getClass().getMethod("setConnectTimeout", new Class[] { int.class }); //$NON-NLS-1$
             if (events != null) {
                 events.debug(Messages.getString("VPNLauncher.runtime5")); //$NON-NLS-1$
             }
             m.invoke(con, new Object[] { new Integer(20000) });
             m = con.getClass().getMethod("setReadTimeout", new Class[] { int.class }); //$NON-NLS-1$
             m.invoke(con, new Object[] { new Integer(20000) });
         } catch (Throwable t) {
         }
         return con.getInputStream();
    }
View Full Code Here

        URL file = new URL(applicationStoreProtocol, applicationStoreHost, applicationStorePort, "/getApplicationFile.do" //$NON-NLS-1$
            + "?name=" + name + "&ticket=" + ticket + "&file=" + filename); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        if (events != null)
            events.debug(MessageFormat.format(Messages.getString("ApplicationLauncher.requestApplicationUsing"), new Object[] { file.toExternalForm() })); //$NON-NLS-1$

        URLConnection con = file.openConnection();
        con.setUseCaches(false);

        try {
            Method m = con.getClass().getMethod("setConnectTimeout", new Class[] { int.class }); //$NON-NLS-1$
            if (events != null) {
                events.debug(Messages.getString("ApplicationLauncher.runtime5")); //$NON-NLS-1$
            }
            m.invoke(con, new Object[] { new Integer(20000) });
            m = con.getClass().getMethod("setReadTimeout", new Class[] { int.class }); //$NON-NLS-1$
            m.invoke(con, new Object[] { new Integer(20000) });
        } catch (Throwable t) {
        }

        return con.getInputStream();
    }
View Full Code Here

                  codebase.getHost(), codebase.getPort() == -1 ? codebase.getProtocol()!=null && codebase.getProtocol().equalsIgnoreCase("http") ? 80 : 443
                                : codebase.getPort(),
                                "/registerClientSynchronization.do?ticket=" + ticket); //$NON-NLS-1$
                System.out.println(MessageFormat.format(Messages.getString("VPNLauncher.sysout.sendingSync"), new Object[] { url })); //$NON-NLS-1$

                URLConnection con = url.openConnection();
                setReadTimeout(con, timeout);

                con.connect();
                System.out.println(MessageFormat.format(Messages.getString("VPNLauncher.sysout.connectedTo"), new Object[] { url } )); //$NON-NLS-1$

                XMLElement result = new XMLElement();
                result.parseFromReader(new InputStreamReader(con.getInputStream()));

                if (result.getName().equalsIgnoreCase("success")) { //$NON-NLS-1$
                    System.out.println(Messages.getString("VPNLauncher.sysout.syncOk")); //$NON-NLS-1$

                    /*
 
View Full Code Here

        Collections.sort(applicationBundlesList);
    }
   
    private void loadDocument() throws IOException, JDOMException {
       
        URLConnection conx = descriptor.openConnection();
        conx.setConnectTimeout(ExtensionStore.CONNECT_TIMEOUT);
        conx.setReadTimeout(ExtensionStore.READ_TIMEOUT);
       
        InputStream in = null;
        try {

            in = conx.getInputStream();
           
            SAXBuilder sax = new SAXBuilder();
            document = sax.build(in);

            if (!document.getRootElement().getName().equalsIgnoreCase("applications")) {
View Full Code Here

    if (log.isInfoEnabled()) {
      log.info("Retrieving RSS feeds from " + url);
    }
   
    URLConnection conx = url.openConnection();
    conx.setConnectTimeout(Feed.CONNECT_TIMEOUT);
    conx.setReadTimeout(Feed.READ_TIMEOUT);
    InputStream inputStream = null;
    try {
      inputStream = conx.getInputStream();
            status = STATUS_LOADING;
            feed = input.build(new XmlReader(inputStream));
            if (log.isInfoEnabled())
              log.info("Retrieved feed " + url);
            status = STATUS_LOADED;
View Full Code Here

  protected void loadAvailable() throws IOException {
    URL location = new URL(baseLocation, "index.txt");
   
    availableFeeds.clear();
    URLConnection conx = location.openConnection();
    conx.setConnectTimeout(CONNECT_TIMEOUT);
    conx.setReadTimeout(READ_TIMEOUT);

    if (log.isInfoEnabled()) {
      log.info("Retrieving RSS feeds index from " + location);
    }
    InputStream inputStream = null;
    try {
      inputStream = conx.getInputStream();
      BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
      String line;
      while ( ( line = reader.readLine() ) != null) {
        availableFeeds.add(line);
      }
View Full Code Here

  public URLConnection downloadExtension(String id, String version) throws IOException {
    URL downloadURL = getDownloadURL(id, version);
    if (downloadURL != null) {
      if (log.isInfoEnabled())
        log.info("Downloading extension from " + downloadURL.toExternalForm());
      URLConnection con = downloadURL.openConnection();
      con.setConnectTimeout(CONNECT_TIMEOUT);
      con.setReadTimeout(READ_TIMEOUT);
      con.connect();
      return con;
    } else {
      throw new IOException("No valid download location for " + id);
    }
  }
View Full Code Here

   * @param request request object
   * @throws ExtensionException extension errors
   * @throws IOException io errors
   */
  public void installExtensionFromStore(String id, String version, HttpServletRequest request) throws IOException, ExtensionException {
    URLConnection connection = downloadExtension(id, version);
    InputStream inputStream = connection.getInputStream();
    installExtensionFromStore(id, inputStream, request, connection.getContentLength());
  }
View Full Code Here

      if (f.isDirectory()) {
        throw new ServletException("Directory listing not allowed");
      }
    }

    URLConnection conx = resource.openConnection();

    if (!passConditionalHeaders(request, response, conx, include))
      return;

    sendData(request, response, pathInContext, resource, conx, include);
View Full Code Here

TOP

Related Classes of java.net.URLConnection

Copyright © 2018 www.massapicom. 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.