//创建字节对象
byte[] buffer;
File file = new File("d://文件转字节测试文档.txt");
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream(fis.available());
byte[] bytes = new byte[fis.available()];
int temp;
while ((temp = fis.read(bytes)) != -1) {
baos.write(bytes, 0, temp);
}
fis.close();
baos.close();
buffer = baos.toByteArray();