-1
我正在经历一个方法的应用程序,请指教一下它基本上做到按我的理解,它读取XML流,并将它作为一个字符串关于XML流
public static final int BUFFER_SIZE = 4096;
protected Object processStream(InputStream inp) throws IOException
{
BufferedInputStream bis = new BufferedInputStream(inp);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream zip = new GZIPOutputStream(baos);
byte[] buffer = new byte[BUFFER_SIZE];
int bufferLength = 0;
while ((bufferLength = bis.read(buffer)) != -1)
{
zip.write(buffer, 0, bufferLength);
zip.flush();
}
zip.close();
baos.close();
return baos.toByteArray();
}
该代码与XML无关,除非'processStream()'的_caller_以XML格式发送。 'processStream()'只是将输入流压缩到内存中的字节数组缓冲区。 –