[quote]byte[]转换为数据流[/quote]
[quote]数据流转换为byte[][/quote]
public static InputStream byteToStream(byte[] b){
try {
ByteArrayInputStream input = new ByteArrayInputStream(b);
return input;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
[quote]数据流转换为byte[][/quote]
public static byte[] streamToByte(InputStream in){
ByteArrayOutputStream str=new ByteArrayOutputStream();
int k;
byte[] b=null;
try {
while((k=in.read())!=-1){
str.write(k);
}
b=str.toByteArray();
str.close();
return b;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}