Package java.net

Examples of java.net.URLConnection.connect()


      for(int i = 0; i < urls.length; i++) {
        URLConnection conn = null;
        try {
          URL url = new URL(urls[i]);
          conn = url.openConnection();
          conn.connect();
        } catch (Exception e) {
          sb.append(" " + urls[i] + ": " + e);
          sb.append("\n");
          nConnectionErrs++;
        } finally {
View Full Code Here


    public List<File> fetchFiles(URL serviceURL, File toDir) throws Exception
    {
        List<File> files = new ArrayList<File>();
        URLConnection conn = serviceURL.openConnection();
        conn.setDoOutput(false); // only true when POSTing
        conn.connect();
        // note, should check 'if (conn.getResponseCode() != 200) ...'
       
        // Ok, let's read it then... (note: StaxMate could simplify a lot!)
        InputStream in = conn.getInputStream();
        XMLStreamReader2 sr = (XMLStreamReader2) _xmlInputFactory.createXMLStreamReader(in);
View Full Code Here

     */
    public Document convertDocument( URL url ) throws IOException
    {
        Document document = new Document();
        URLConnection connection = url.openConnection();
        connection.connect();
        // Add the url as a field named "url".  Use an UnIndexed field, so
        // that the url is just stored with the document, but is not searchable.
        addUnindexedField( document, "url", url.toExternalForm() );

        // Add the last modified date of the file a field named "modified".  Use a
View Full Code Here

                if (log.isDebugEnabled()) {
                    log.debug("Cannot create a URLConnection for given URL : " + url);
                }
                return null;
            }
            connection.connect();
            inputStream = new BufferedInputStream(connection.getInputStream());
        } catch (IOException e) {
            return null;
        }
View Full Code Here

    private long readDTM(URL url) throws Exception
    {
        URLConnection connection = url.openConnection();

        connection.connect();

        return connection.getLastModified();
    }

    private void createSynthComponentClass(String name) throws CannotCompileException, NotFoundException, IOException
View Full Code Here

        }

        connection.setRequestProperty( "Pragma", "no-cache" );

        //connect to the remote site (may take some time)
        connection.connect();
        //next test for a 304 result (HTTP only)
        if ( connection instanceof HttpURLConnection )
        {
            HttpURLConnection httpConnection = (HttpURLConnection) connection;
            // although HTTPUrlConnection javadocs says FileNotFoundException should be
View Full Code Here

            conn.setRequestProperty("Accept-Charset", "utf-8,*") ;
            conn.setDoInput(true) ;
            conn.setDoOutput(false) ;
            // Default is true.  See javadoc for HttpURLConnection
            //((HttpURLConnection)conn).setInstanceFollowRedirects(true) ;
            conn.connect() ;
            InputStream in = new BufferedInputStream(conn.getInputStream());
           
            if ( FileManager.logAllLookups  && log.isTraceEnabled() )
                log.trace("Found: "+filenameOrURI) ;
            return new TypedStream(in, conn.getContentType()) ;
View Full Code Here

                    log.warn("Unexpected response code while validating repository ("+result+" "+con.getResponseMessage()+").  Assuming you know what you're doing.");
                }
                con.disconnect();
            } else {
                try {
                    urlConnection.connect();
                    InputStream in = urlConnection.getInputStream();
                    in.read();
                    in.close();
                } catch (IOException e) {
                    response.setRenderParameter("repoError", "Not a valid repository; no plugin list found at "+test);
View Full Code Here

        URL url = new URL(target);

        URLConnection connection = url.openConnection();

        assertTrue(connection instanceof HttpURLConnection);
        connection.connect();
        InputStream in = connection.getInputStream();
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        IOUtils.copy(in, buffer);
        return buffer.toString();
    }
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

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.