/**
* 从inputStream中读取数据
* @param is
* @return
* @throws IOException
*/
public static byte[] read(InputStream is) throws IOException{
List<Byte> ls = new ArrayList<Byte>();
byte[] readData = null;
if(null != is){
int v = is.read();
while(v!=-1){
ls.add((byte)v);
v = is.read();
}
}
int size = ls.size();
if(size > 0){
readData = new byte[ls.size()];
for(int i=0; i<size; i++){
readData[i] = ls.get(i);
}
}
return readData;
}
这个应该实现不间断的读取InputStream返回的所有数据。暂时不清楚有没有其他什么问题!也欢迎大家提出意见,一起进步。