4

I have read through the Security with HTTPS and SSL documentation from Android. I see that it keeps using copyInputStreamToOutputStream(in, System.out);. That gives me

error: cannot find symbol method copyInputStreamToOutputStream(InputStream,PrintStream)

Here's the code in question:

URL url = new URL("https://wikipedia.org");
URLConnection urlConnection = url.openConnection();
InputStream in = urlConnection.getInputStream();
copyInputStreamToOutputStream(in, System.out);

What is the meaning of copyInputStreamToOutputStream?

Mathieu K.
  • 283
  • 3
  • 14
Dave Cruise
  • 443
  • 7
  • 16
  • Looks like a method to copy an input stream to an output stream to me. They don't seem to provide it but it's only six lines of code or so. – user207421 Oct 06 '16 at 03:17

1 Answers1

1

Easy way to write contents of a Java InputStream to an OutputStream

org.apache.commons.io.IOUtils from Apache has a method called copy(InputStream,OutputStream) which does exactly what you're looking for.

IOUtils.copy(in,out);

Community
  • 1
  • 1
deathyr
  • 433
  • 2
  • 11