关于java:copyInputStreamToOutputStream(in,System.out)

copyInputStreamToOutputStream(in, System.out)

本问题已经有最佳答案,请猛点这里访问。

我已经阅读了Android提供的HTTPS和SSL文档的安全性。我看到它一直在使用copyInputStreamToOutputStream(in, System.out);。这给了我

江户十一〔一〕号

下面是有问题的代码:

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

copyInputStreamToOutputStream的意思是什么?


将Java输入流的内容写入输出流的简单方法

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);