URLConnection setDoInput - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for URLConnection setDoInput method.

This code example shows how to use the following methods:setDoInput
        final URL url = new URL(spec); 
        Callable<String> task = new Callable<String>() { 
            @Override 
            public String call() throws Exception { 
                final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 
                conn.setDoInput(true); 
                return processResponse(conn); 
            } 
        }; 
        return execute(task, timeout, unit); 
    } 
 
    /** 
     * Returns the URL response as a string. 
     * 
     * @param spec  URL spec 
     * @param waitUntilAvailableMs  maximum timeout in milliseconds to wait for the URL to return non 404 response 
     * @param responseTimeout  the timeout to read the response 
     * @param responseTimeoutUnit  the time unit for responseTimeout 
     * @return  URL response 
7
CodeRank
This code example shows how to use the following methods:setRequestMethod, setDoInput, setDoOutput, setRequestProperty, setUseCaches
		} 
		return new Request.Builder().source("com.apple.maps").unknown3(0).unknown4(0).wifis(wifis).build(); 
	} 
 
	private static void prepareConnection(HttpsURLConnection connection, int length) throws ProtocolException {
		connection.setRequestMethod("POST");
		connection.setDoInput(true);
		connection.setDoOutput(true);
		connection.setUseCaches(false);
		connection.setRequestProperty(HTTP_FIELD_CONTENT_TYPE, CONTENT_TYPE_URLENCODED);
		connection.setRequestProperty(HTTP_FIELD_CONTENT_LENGTH, String.valueOf(length));
	} 
 
	public Response retrieveLocations(String... macs) throws IOException {
		Request request = createRequest(macs);
		byte[] byteb = request.toByteArray();
		byte[] bytes = combineBytes(APPLE_MAGIC_BYTES, byteb, (byte) byteb.length);
		HttpsURLConnection connection = createConnection();
		prepareConnection(connection, bytes.length);
		OutputStream out = connection.getOutputStream();
7
CodeRank
This code example shows how to use the following methods:connect, getInputStream, setDoInput
This code example shows how to use the following methods:setRequestMethod, setConnectTimeout, setDoInput, setDoOutput, setReadTimeout
    } 
 
    private HttpURLConnection openConnection(URL targetUrl) throws IOException {
        HttpURLConnection conn = (HttpURLConnection) targetUrl.openConnection();
        if (0 < getTimeoutMillis()) { 
            conn.setConnectTimeout(getTimeoutMillis());
            conn.setReadTimeout(getTimeoutMillis());
        } 
        if (isTryGzip()) { 
            conn.setRequestProperty("Accept-Encoding", "gzip");
        } 
 
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);
        conn.setDoInput(true);
        return conn;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:connect, getInputStream, setDoInput
            URL url;
 
            url = new URL( urlstr );
 
            HttpURLConnection c = ( HttpURLConnection ) url.openConnection();
            c.setDoInput( true );
            c.connect();
            InputStream is = c.getInputStream();
            Bitmap img;
            img = BitmapFactory.decodeStream( is );
            return img;
        } 
        catch ( MalformedURLException e )
        { 
            Log.d( "RemoteImageHandler", "RemoteImageWorker passed invalid URL: " + urlstr );
        } 
        catch ( IOException e )
        { 
            Log.d( "RemoteImageHandler", "RemoteImageWorker IO exception: " + e );
        } 
7
CodeRank
This code example shows how to use the following methods:getJarFile, connect, setAllowUserInteraction, setDoInput, setDoOutput
log.debug("JarHolder: attempting to connect to " + urlpath);
            } 
            URL url = new URL( urlpath );
            conn = (JarURLConnection) url.openConnection();
            conn.setAllowUserInteraction(false);
            conn.setDoInput(true);
            conn.setDoOutput(false);
            conn.connect();
            theJar = conn.getJarFile();
        } 
        catch (IOException ioe)
        { 
            String msg = "JarHolder: error establishing connection to JAR at \""
                         + urlpath + "\"";
            log.error(msg, ioe);
            throw new VelocityException(msg, ioe);
        } 
    } 
 
7
CodeRank
This code example shows how to use the following methods:setDoInput
  @Override 
  public BufferedReader getInput() throws IOException
  { 
    URL url = new URL(urlString);
    URLConnection connection = url.openConnection();
    connection.setDoInput(true);
    return new BufferedReader(new InputStreamReader(url.openStream()));
  } 
} 
7
CodeRank
This code example shows how to use the following methods:setRequestMethod, getHeaderField, setDoInput
            } 
            case URI_TYPE_HTTP:
            case URI_TYPE_HTTPS: {
                try { 
                    HttpURLConnection conn = httpClient.open(new URL(uri.toString()));
                    conn.setDoInput(false);
                    conn.setRequestMethod("HEAD");
                    return conn.getHeaderField("Content-Type");
                } catch (IOException e) {
                } 
            } 
        } 
         
        return null; 
    } 
     
    private String getMimeTypeFromPath(String path) {
        String extension = path;
        int lastDot = extension.lastIndexOf('.');
        if (lastDot != -1) {
7
CodeRank
This code example shows how to use the following methods:setRequestMethod, setConnectTimeout, setDoInput, setReadTimeout
        AndroidUtils.disableConnectionReuseIfNecessary(); 
 
        URL url = new URL(urlString);
 
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setReadTimeout(10000 /* milliseconds */);
        conn.setConnectTimeout(15000 /* milliseconds */);
        conn.setDoInput(true);
        conn.setRequestMethod("GET");
        return conn;
    } 
 
    /** 
     * Prior to Android 2.2 (Froyo), {@link HttpURLConnection} had some 
     * frustrating bugs. In particular, calling close() on a readable 
     * InputStream could poison the connection pool. Work around this by 
     * disabling connection pooling. 
     */ 
    public static void disableConnectionReuseIfNecessary() { 
        // HTTP connection reuse which was buggy pre-froyo 
8
CodeRank
This code example shows how to use the following methods:setRequestMethod, setDoInput, setDoOutput, setReadTimeout

Related URLConnection setDoInput Questions & Answers:

setDoInput Method Overview
Sets the value of the doInput field for this URLConnection to the specified value.
See Code Examples for other Java 8 URLConnection Methods: