JAVA将Byte数组(byte[])转换成⽂件/**
* 将Byte数组转换成⽂件
* @param bytes byte数组
* @param filePath ⽂件路径如 D://test/ 最后“/”结尾
* @param fileName  ⽂件名
*/
public static void fileToBytes(byte[] bytes, String filePath, String fileName) {
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
try {
file = new File(filePath + fileName);
if (!ParentFile().exists()){
//⽂件夹不存在⽣成
}
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(bytes);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fos != null) {
try {
java64位fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}