我從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
但只要它得到了記錄。流越來越封閉:(