Tabnine Logo
URLConnection.setDoInput
Code IndexAdd Tabnine to your IDE (free)

How to use
setDoInput
method
in
java.net.URLConnection

Best Java code snippets using java.net.URLConnection.setDoInput (Showing top 20 results out of 6,030)

Refine searchRefine arrow

  • URL.openConnection
  • URL.<init>
  • URLConnection.getInputStream
  • URLConnection.setDoOutput
  • HttpURLConnection.setRequestMethod
  • URLConnection.getOutputStream
origin: stackoverflow.com

 URL url = new URL(user_image_url);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();   
conn.setDoInput(true);   
conn.connect();     
InputStream is = conn.getInputStream();
bmImg = BitmapFactory.decodeStream(is);
origin: jphp-group/jphp

public URLConnection getURLConnection() throws IOException {
  if (urlConnection == null) {
    if (proxy != null) {
      urlConnection = url.openConnection(proxy);
    } else {
      urlConnection = url.openConnection();
    }
    urlConnection.setDoInput(false);
    urlConnection.setDoOutput(false);
    if (getMode().startsWith("r") || getMode().startsWith("w") || getMode().startsWith("a")) {
      urlConnection.setDoInput(true);
    }
    if (getMode().startsWith("w") || getMode().startsWith("a")) {
      urlConnection.setDoOutput(true);
    }
  }
  return urlConnection;
}
origin: stackoverflow.com

 URL myURL = new URL(serviceURL);
HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection();
String userCredentials = "username:password";
String basicAuth = "Basic " + new String(new Base64().encode(userCredentials.getBytes()));
myURLConnection.setRequestProperty ("Authorization", basicAuth);
myURLConnection.setRequestMethod("POST");
myURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
myURLConnection.setRequestProperty("Content-Length", "" + postData.getBytes().length);
myURLConnection.setRequestProperty("Content-Language", "en-US");
myURLConnection.setUseCaches(false);
myURLConnection.setDoInput(true);
myURLConnection.setDoOutput(true);
origin: stackoverflow.com

 public static Bitmap getBitmapFromURL(String src) {
  try {
    URL url = new URL(src);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.connect();
    InputStream input = connection.getInputStream();
    Bitmap myBitmap = BitmapFactory.decodeStream(input);
    return myBitmap;
  } catch (IOException e) {
    // Log exception
    return null;
  }
}
origin: stackoverflow.com

 URL url = new URL("http://yoururl.com");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setReadTimeout(10000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);

Uri.Builder builder = new Uri.Builder()
    .appendQueryParameter("firstParam", paramValue1)
    .appendQueryParameter("secondParam", paramValue2)
    .appendQueryParameter("thirdParam", paramValue3);
String query = builder.build().getEncodedQuery();

OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(
      new OutputStreamWriter(os, "UTF-8"));
writer.write(query);
writer.flush();
writer.close();
os.close();

conn.connect();
origin: stackoverflow.com

 public Bitmap getBitmapFromURL(String strURL) {
  try {
    URL url = new URL(strURL);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.connect();
    InputStream input = connection.getInputStream();
    Bitmap myBitmap = BitmapFactory.decodeStream(input);
    return myBitmap;
  } catch (IOException e) {
    e.printStackTrace();
    return null;
  }
}
origin: stackoverflow.com

 public Bitmap getBitmapFromURL(String strURL) {
  try {
    URL url = new URL(strURL);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.connect();
    InputStream input = connection.getInputStream();
    Bitmap myBitmap = BitmapFactory.decodeStream(input);
    return myBitmap;
  } catch (IOException e) {
    e.printStackTrace();
    return null;
  }
}
origin: stackoverflow.com

String response = "";
try {
  url = new URL(requestURL);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setReadTimeout(15000);
  conn.setConnectTimeout(15000);
  conn.setRequestMethod("POST");
  conn.setDoInput(true);
  conn.setDoOutput(true);
  OutputStream os = conn.getOutputStream();
  BufferedWriter writer = new BufferedWriter(
      new OutputStreamWriter(os, "UTF-8"));
    BufferedReader br=new BufferedReader(new InputStreamReader(conn.getInputStream()));
    while ((line=br.readLine()) != null) {
      response+=line;
origin: neo4j/neo4j

void ping() throws IOException
{
  pingCount++;
  Map<String, String> usageDataMap = collector.getUdcParams();
  StringBuilder uri = new StringBuilder( "http://" + address + "/" + "?" );
  for ( Map.Entry<String,String> entry : usageDataMap.entrySet() )
  {
    uri.append( entry.getKey() );
    uri.append( "=" );
    uri.append( URLEncoder.encode( entry.getValue(), StandardCharsets.UTF_8.name() ) );
    uri.append( "+" );
  }
  uri.append( PING + "=" ).append( pingCount );
  URL url = new URL( uri.toString() );
  URLConnection con = url.openConnection();
  con.setDoInput( true );
  con.setDoOutput( false );
  con.setUseCaches( false );
  con.connect();
  con.getInputStream().close();
}
origin: stackoverflow.com

 public static Bitmap getBitmapFromURL(String src) {
  try {
    Log.e("src",src);
    URL url = new URL(src);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.connect();
    InputStream input = connection.getInputStream();
    Bitmap myBitmap = BitmapFactory.decodeStream(input);
    Log.e("Bitmap","returned");
    return myBitmap;
  } catch (IOException e) {
    e.printStackTrace();
    Log.e("Exception",e.getMessage());
    return null;
  }
}
origin: stackoverflow.com

 public Bitmap getBitmapFromURL(String src) {
  try {
    java.net.URL url = new java.net.URL(src);
    HttpURLConnection connection = (HttpURLConnection) url
        .openConnection();
    connection.setDoInput(true);
    connection.connect();
    InputStream input = connection.getInputStream();
    Bitmap myBitmap = BitmapFactory.decodeStream(input);
    return myBitmap;
  } catch (IOException e) {
    e.printStackTrace();
    return null;
  }
}
origin: robovm/robovm

/**
 * Opens an InputStream for the given URL.
 */
/*package*/ static InputStream openUrl(String url) throws IOException {
  try {
    URLConnection urlConnection = new URL(url).openConnection();
    urlConnection.setConnectTimeout(TIMEOUT);
    urlConnection.setReadTimeout(TIMEOUT);
    urlConnection.setDoInput(true);
    urlConnection.setDoOutput(false);
    return urlConnection.getInputStream();
  } catch (Exception e) {
    IOException ioe = new IOException("Couldn't open " + url);
    ioe.initCause(e);
    throw ioe;
  }
}
origin: stackoverflow.com

 URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream  input;
url = new URL (getCodeBase().toString() + "env.tcgi");
urlConn = url.openConnection();
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setRequestProperty("Content-Type","application/json");   
urlConn.setRequestProperty("Host", "android.schoolportal.gr");
urlConn.connect();  
//Create JSONObject here
JSONObject jsonParam = new JSONObject();
jsonParam.put("ID", "25");
jsonParam.put("description", "Real");
jsonParam.put("enable", "true");
origin: jphp-group/jphp

@Signature
public static URLConnection create(String url, @Nullable Proxy proxy) throws IOException {
  URL _url = new URL(url);
  URLConnection urlConnection = proxy == null ? _url.openConnection() : _url.openConnection(proxy);
  urlConnection.setDoOutput(true);
  urlConnection.setDoInput(true);
  if (urlConnection instanceof HttpURLConnection) {
    HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
    httpURLConnection.setRequestMethod("GET");
  }
  return urlConnection;
}
origin: stackoverflow.com

 URL url = new URL("http","www.google.com");
HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
urlc.setAllowUserInteraction( false );
urlc.setDoInput( true );
urlc.setDoOutput( false );
urlc.setUseCaches( true );
urlc.setRequestMethod("GET");
urlc.connect();
// check you have received an status code 200 to indicate OK
// get the encoding from the Content-Type header
BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
String line = null;
while((line = in.readLine()) != null) {
 System.out.println(line);
}

// close sockets, handle errors, etc.
origin: stackoverflow.com

String response = "";
try {
  url = new URL(requestURL);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setReadTimeout(15000);
  conn.setConnectTimeout(15000);
  conn.setRequestMethod("GET");
  conn.setDoInput(true);
  conn.setDoOutput(true);
  OutputStream os = conn.getOutputStream();
  BufferedWriter writer = new BufferedWriter(
      new OutputStreamWriter(os, "UTF-8"));
    BufferedReader br=new BufferedReader(new InputStreamReader(conn.getInputStream()));
    while ((line=br.readLine()) != null) {
      response+=line;
origin: stackoverflow.com

 @Override
    protected Void doInBackground(Void... params) {             
      try {
        URL myFileUrl = new URL("http://sposter.smartag.my/images/chicken_soup.jpg");
        HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
        conn.setDoInput(true);
        conn.connect();
        InputStream is = conn.getInputStream();
        downloadBitmap = BitmapFactory.decodeStream(is);
              } catch (FileNotFoundException e) {             
        e.printStackTrace();
      }
      catch (IOException e) {         
        e.printStackTrace();
      }               
      return null;
    }

@Override
onPostExecute()
{
 ImageView image = (ImageView) findViewById(R.id.imview);            
      image.setImageBitmap(downloadBitmap);
}
origin: stackoverflow.com

 public static String sendPostRequest(String requestUrl, String payload) {
  try {
    URL url = new URL(requestUrl);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();

    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Accept", "application/json");
    connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
    OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
    writer.write(payload);
    writer.close();
    BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    StringBuffer jsonString = new StringBuffer();
    String line;
    while ((line = br.readLine()) != null) {
        jsonString.append(line);
    }
    br.close();
    connection.disconnect();
  } catch (Exception e) {
      throw new RuntimeException(e.getMessage());
  }
  return jsonString.toString();
}
origin: stackoverflow.com

 private StringBuffer request(String urlString) {
  // TODO Auto-generated method stub

  StringBuffer chaine = new StringBuffer("");
  try{
    URL url = new URL(urlString);
    HttpURLConnection connection = (HttpURLConnection)url.openConnection();
    connection.setRequestProperty("User-Agent", "");
    connection.setRequestMethod("POST");
    connection.setDoInput(true);
    connection.connect();

    InputStream inputStream = connection.getInputStream();

    BufferedReader rd = new BufferedReader(new InputStreamReader(inputStream));
    String line = "";
    while ((line = rd.readLine()) != null) {
      chaine.append(line);
    }
  }
  catch (IOException e) {
    // Writing exception to log
    e.printStackTrace();
  }
  return chaine;
}
origin: stackoverflow.com

protected Bitmap doInBackground(Void... params) {
  try {
    URL urlConnection = new URL(url);
    HttpURLConnection connection = (HttpURLConnection) urlConnection
        .openConnection();
    connection.setDoInput(true);
    connection.connect();
    InputStream input = connection.getInputStream();
    Bitmap myBitmap = BitmapFactory.decodeStream(input);
    return myBitmap;
java.netURLConnectionsetDoInput

Javadoc

Sets the flag indicating whether this URLConnection allows input. It cannot be set after the connection is established.

Popular methods of URLConnection

  • getInputStream
    Returns an input stream that reads from this open connection. A SocketTimeoutException can be thrown
  • setUseCaches
    Sets the value of the useCaches field of thisURLConnection to the specified value. Some protocols do
  • connect
    Opens a communications link to the resource referenced by this URL, if such a connection has not alr
  • setRequestProperty
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • getOutputStream
    Returns an output stream that writes to this connection.
  • getLastModified
    Returns the value of the last-modified header field. The result is the number of milliseconds since
  • setConnectTimeout
    Sets a specified timeout value, in milliseconds, to be used when opening a communications link to th
  • setDoOutput
    Sets the value of the doOutput field for thisURLConnection to the specified value. A URL connection
  • getContentLength
    Returns the value of the content-length header field.Note: #getContentLengthLong()should be preferre
  • setReadTimeout
    Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeou
  • getContentType
    Returns the value of the content-type header field.
  • getHeaderField
    Returns the value of the named header field. If called on a connection that sets the same header mul
  • getContentType,
  • getHeaderField,
  • addRequestProperty,
  • getURL,
  • getContentEncoding,
  • guessContentTypeFromName,
  • setDefaultUseCaches,
  • getFileNameMap,
  • getContent

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Collectors (java.util.stream)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JOptionPane (javax.swing)
  • Table (org.hibernate.mapping)
    A relational table
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now