Package java.net

Examples of java.net.URLConnection$DefaultContentHandler


        try {
            // create the URL object
            URL url = new URL(yahooUrl);
           
            // create the connection to the URL
            URLConnection conn = url.openConnection();

            // establish the connection to the URL                         
            conn.connect();
           
            // get the stream from the commection
            inSR = new InputStreamReader(conn.getInputStream());
           
            // place the stream into a buffered reader
            buffReader = new BufferedReader(inSR);         
           
            // now read each line from the Yahoo! Source and place
View Full Code Here


    int numPackages = -1;
    try {
      PACKAGE_MANAGER.setPackageRepositoryURL(REP_URL);
      String numPackagesS = PACKAGE_MANAGER.getPackageRepositoryURL().toString()
      + "/numPackages.txt";
      URLConnection conn = null;
      URL connURL = new URL(numPackagesS);

      if (PACKAGE_MANAGER.setProxyAuthentication()) {
        conn = connURL.openConnection(PACKAGE_MANAGER.getProxy());
      } else {
        conn = connURL.openConnection();
      }
     
      conn.setConnectTimeout(30000); // timeout after 30 seconds
     
      BufferedReader bi =
        new BufferedReader(new InputStreamReader(conn.getInputStream()));
     
      String n = bi.readLine();
      try {
        numPackages = Integer.parseInt(n);
      } catch (NumberFormatException ne) {
View Full Code Here

      PACKAGE_MANAGER.setPackageRepositoryURL(REP_URL);
    }
   
    String packageListS = PACKAGE_MANAGER.getPackageRepositoryURL().toString()
    + "/packageList.txt";
    URLConnection conn = null;
    URL connURL = new URL(packageListS);

    if (PACKAGE_MANAGER.setProxyAuthentication()) {
      conn = connURL.openConnection(PACKAGE_MANAGER.getProxy());
    } else {
      conn = connURL.openConnection();
    }
   
    conn.setConnectTimeout(30000); // timeout after 30 seconds
   
    BufferedReader bi =
      new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String l = null;
    while ((l = bi.readLine()) != null) {
      result.put(l,l);
    }
    bi.close();
View Full Code Here

            URLClassLoader  current = (URLClassLoader)plugin_class_loader;

            URL url = current.findResource("plugin.properties");

            if ( url != null ){
              URLConnection connection = url.openConnection();

              InputStream is = connection.getInputStream();

              props.load(is);

            }else{
View Full Code Here

            return null;
        }

        try {
            URL url = new URL(location);
            URLConnection con = url.openConnection();

            // do we have if-modified-since or etag headers to set?
            if (condition != null && condition != Undefined.instance) {
                if (condition instanceof Scriptable) {
                    Scriptable scr = (Scriptable) condition;
                    if ("Date".equals(scr.getClassName())) {
                        Date date = new Date((long) ScriptRuntime.toNumber(scr));

                        con.setIfModifiedSince(date.getTime());

                        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz",
                                                                   Locale.UK);

                        format.setTimeZone(TimeZone.getTimeZone("GMT"));
                        con.setRequestProperty("If-Modified-Since", format.format(date));
                    }else {
                        con.setRequestProperty("If-None-Match", scr.toString());
                    }
                } else {
                    con.setRequestProperty("If-None-Match", condition.toString());
                }
            }

            String httpUserAgent = app.getProperty("httpUserAgent");

            if (httpUserAgent != null) {
                con.setRequestProperty("User-Agent", httpUserAgent);
            }

            if (timeout != null && timeout != Undefined.instance) {
                int time = ScriptRuntime.toInt32(timeout);
                con.setConnectTimeout(time);
                con.setReadTimeout(time);
            }

            con.setAllowUserInteraction(false);

            String filename = url.getFile();
            String contentType = con.getContentType();
            long lastmod = con.getLastModified();
            String etag = con.getHeaderField("ETag");
            int length = con.getContentLength();
            int resCode = 0;

            if (con instanceof HttpURLConnection) {
                resCode = ((HttpURLConnection) con).getResponseCode();
            }

            ByteArrayOutputStream body = new ByteArrayOutputStream();

            if ((length != 0) && (resCode != 304)) {
                InputStream in = new BufferedInputStream(con.getInputStream());
                byte[] b = new byte[1024];
                int read;

                while ((read = in.read(b)) > -1)
                    body.write(b, 0, read);
View Full Code Here

   
    // Get an InputStream based on a publicid and a systemid
    private InputStream getInputStream(String publicid, String systemid) throws IOException, SAXException {
        URL basis = new URL("file", "", System.getProperty("user.dir") + "/.");
        URL url = new URL(basis, systemid);
        URLConnection c = url.openConnection();
        return c.getInputStream();
    }
View Full Code Here

    try {
      return new URL(null, "temp:#temp", new URLStreamHandler() { //$NON-NLS-1$
       
        @Override
        protected URLConnection openConnection(URL u) throws IOException {
          return new URLConnection(u) {
           
            @Override
            public void connect() throws IOException {
             
            }
View Full Code Here

      Vector al = null;
      ObjectInputStream inFromServlet = null;
      try {

         URL studentDBservlet = new URL( requestUrl );
         URLConnection servletConnection = studentDBservlet.openConnection();
         servletConnection.setDoInput(true);
         servletConnection.setDoOutput(true);
         servletConnection.setUseCaches (false);
         servletConnection.setRequestProperty
             ("Content-Type", "application/octet-stream");
         inFromServlet = new ObjectInputStream(servletConnection.getInputStream());
         al = (Vector) inFromServlet.readObject();
      }
      catch (ClassNotFoundException e) {

         e.printStackTrace();
View Full Code Here

        + "&peer_id="   + URLEncoder.encode(new String(peerId, Constants.BYTE_ENCODING), Constants.BYTE_ENCODING).replaceAll("\\+", "%20")
        + "&port=" + port
        + "&uploaded=0&downloaded=0&left=0&numwant=50&no_peer_id=1&compact=1";
      //System.out.println(strUrl);
      URL url = new URL(strUrl);
      URLConnection con = url.openConnection();
      con.connect();
      con.getContent();
    } catch(Exception e) {
      e.printStackTrace();
    }   
  }
View Full Code Here

        while (loader != null) {
            if (loader instanceof URLClassLoader) {
                URL[] urls = ((URLClassLoader) loader).getURLs();
                for (int i=0; i<urls.length; i++) {
                    URLConnection conn = urls[i].openConnection();
                    if (conn instanceof JarURLConnection) {
                        if (needScanJar(loader, webappLoader,
                                        ((JarURLConnection) conn).getJarFile().getName())) {
                            scanJar((JarURLConnection) conn, true);
                        }
View Full Code Here

TOP

Related Classes of java.net.URLConnection$DefaultContentHandler

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.