Java通过接口返回文件流
public byte[] fileUrlToBytes(String fileUrl) {
FileInputStream inputStream = null;
byte[] bytes = null;
try {
File file = new File(fileUrl);
inputStream = new FileInputStream(file);
bytes = new byte[inputStream.available()];
inputStream.read(bytes,0,inputStream.available());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return bytes;
}