我从http连接获取流数据。 我想使用log4j将流记录到日志文件。使用log4j记录流数据
我需要这个流还做一些其他操作(必须保留)
我怎么能这样做?
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/xml");
InputStream xml = connection.getInputStream();
我想这一个:
StreamUtils.copy(xml, new LogOutputStreamUtil(log, Level.INFO));
其中LogOutputStreamUtil从http://www.java2s.com/Open-Source/Java/Testing/jacareto/jacareto/toolkit/log4j/LogOutputStream.java.htm
但只要它得到了记录。流越来越封闭:(