code: public static void transferURLStream(InputStream streamIn, OutputStream streamOut)
      {
      	try {
              byte[] cbuf = new byte[1000];
              int iLen = 0;
              while ((iLen = streamIn.read(cbuf, 0, cbuf.length)) > 0)
              {   // Write the entire file to the output buffer
              	streamOut.write(cbuf, 0, iLen);
              }
              streamIn.close();
              if (streamIn != null)
              	streamIn.close();
          } catch (MalformedURLException ex)  {
              ex.printStackTrace();
          } catch (IOException ex) {
              ex.printStackTrace();
          }
      }
docs: Transfer the data stream from this URL to another stream.
  @param strURL The URL to read.
  @param strFilename If non-null, create this file and send the URL data here.
  @param strFilename If null, return the stream as a string.
  @param in If this is non-null, read from this input source.
  @return The stream as a string if filename is null.