Package java.net

Examples of java.net.URLConnection.connect()


            // apply the checksum
            if (cs != null) {
                cs.set((HttpURLConnection) urlConnection, checksum);
            }
           
            urlConnection.connect();
            response = ((HttpURLConnection) urlConnection).getResponseCode();
           
            if (cs != null) {
                responseChecksum = cs.get((HttpURLConnection) urlConnection);
            }
View Full Code Here


            URL url = new URL(urlString);
            urlConnection = url.openConnection();
            if (lastModified != -1) {
                urlConnection.setIfModifiedSince(lastModified);
            }
            urlConnection.connect();
            response = ((HttpURLConnection) urlConnection).getResponseCode();
            responseLastModified = urlConnection.getLastModified();
        } catch (IOException excp) {
            logger.log(Level.WARNING, "Unable to open URL for asset " +
                    urlString, excp);
View Full Code Here

    String connection = "OK";
    final URL url = new URL("http://code.google.com/p/tamt");
    try
    {
      final URLConnection conn = url.openConnection();
      conn.connect();
    } catch (IOException e)
    {
      connection = "NOCONNECTION";
      logger.error("Could not connect:" + e.getMessage());
    }
View Full Code Here

        String fileName = "";
        int count;
        try {
            URL url = new URL(urlString);
            URLConnection conexion = url.openConnection();
            conexion.connect();
            // this will be useful so that you can show a tipical 0-100% progress bar
            int lenghtOfFile = conexion.getContentLength();
            fileName = urlString.substring(urlString.lastIndexOf("/") + 1);
            // downlod the file
            InputStream input = new BufferedInputStream(url.openStream());
View Full Code Here

    String downloadLink = GoogleDownloadLinkGenerator.generateXlDownloadLink(uploadedExcelDocumentID);

    URL url = new URL(downloadLink);
    URLConnection urlConnection = url.openConnection();
    urlConnection.connect();
    InputStream input = url.openStream();
    FileWriter fw = new FileWriter("tmpOutput.kb");


    Reader reader = new InputStreamReader(input);
View Full Code Here

    String downloadLink = GoogleDownloadLinkGenerator.generateTextDownloadLink(uploadedKbDocumentID);

    URL url = new URL(downloadLink);
    URLConnection urlConnection = url.openConnection();
    urlConnection.connect();
    InputStream input = url.openStream();
    FileWriter fw = new FileWriter("tmpOutput.kb");


    Reader reader = new InputStreamReader(input);
View Full Code Here

                try {
                    URLConnection connection = absoluteURL.openConnection();
                    connection.setAllowUserInteraction(false);
                    connection.setDoInput(true);
                    updateURLConnection(connection, href);
                    connection.connect();
                    return new StreamSource(connection.getInputStream(), effURL);
                } catch (FileNotFoundException fnfe) {
                    // Note: This is on "debug" level since the caller is
                    // supposed to handle this
                    log.debug("File not found: " + effURL);
View Full Code Here

     */
    public static URLType getType(URL url) throws IOException {
        if (url.toString().endsWith("/")) {
            URL metaInfURL = new URL(url, MANIFEST_LOCATION);
            URLConnection urlConnection = metaInfURL.openConnection();
            urlConnection.connect();
            try {
                InputStream is = urlConnection.getInputStream();
                is.close();
                return UNPACKED_ARCHIVE;
            } catch (IOException e) {
View Full Code Here

            }
        } else {
            if(username != null && !username.equals("")) {
                con.setRequestProperty("Authorization", "Basic " + new String(Base64.encode((username + ":" + password).getBytes())));
                try {
                    con.connect();
                    if(monitor != null && con.getContentLength() > 0) {
                        monitor.setTotalBytes(con.getContentLength());
                    }
                    return con.getInputStream();
                } catch (FileNotFoundException e) {
View Full Code Here

                } catch (FileNotFoundException e) {
                    return null;
                }
            } else {
                try {
                    con.connect();
                    if(monitor != null && con.getContentLength() > 0) {
                        monitor.setTotalBytes(con.getContentLength());
                    }
                    return con.getInputStream();
                } catch (FileNotFoundException e) {
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.