---
title: "android中将读回的xml inputstream打印为日志"
author: "googlelee"
date: "2012-05-21T10:40:33Z"
tags: []
categories: ["移动开发"]
slug: "android-xml-inputstream"
draft: false
lastmod: "2012-05-21T10:40:33Z"
id: 1536075
url: "https://googlelee.iteye.com/blog/1536075"
---

if(StringUtils.IsShowLog) {

try {

ByteArrayOutputStream os=new ByteArrayOutputStream();

byte\[] b = new byte\[4096];  

for (int n; (n = is.read(b)) != -1;) {

   StringUtils.logD(tag, ""+new String(b, 0, n));

   os.write(b, 0, n);

}

InputStream is\_temp = new ByteArrayInputStream(os.toByteArray());

is = is\_temp;

} catch (IOException e1) {

e1.printStackTrace();

}   

}