OutputStream baos = new ByteArrayOutputStream();
byte[] content = baos.toByteArray();
文件的读写
byte[] in2b = null;
ByteArrayOutputStream swapStream = null;
InputStream fis = null;
String filePath = "";
try {
filePath = "D://bpm.docx";
fis = new FileInputStream(new File(filePath));
swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[1024];
int rc = 0;
while ((rc = fis.read(buff, 0, 1024)) > 0) {
swapStream.write(buff, 0, rc);
}
in2b = swapStream.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
fis.close();
swapStream.close();
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return in2b;