-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()'只是將輸入流壓縮到內存中的字節數組緩衝區。 –