If you need a demo code , try the following:
URL url = new URL("url.com"); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); try { InputStream in = new BufferedInputStream(urlConnection.getInputStream()); readStream(in); } finally { urlConnection.disconnect(); }
and this:
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); try { urlConnection.setDoOutput(true); urlConnection.setChunkedStreamingMode(0); OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream()); writeStream(out); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); readStream(in); } finally { urlConnection.disconnect(); }
Hope this helps.
source share