javaå°æ件转æ¢ä¸ºbyteæ°ç»ï¼ä¸»è¦æ¯ä½¿ç¨è¾åºæµï¼å®ä¾å¦ä¸ï¼
/**
* æ ¹æ®byteæ°ç»ï¼çææ件
*/
public static void getFile(byte[] bfile, String filePath,String fileName) {
BufferedOutputStream bos = null; //æ°å»ºä¸ä¸ªè¾åºæµ
FileOutputStream fos = null; //wæ件å
è£
è¾åºæµ
File file = null;
try {
File dir = new File(filePath);
if(!dir.exists()&&dir.isDirectory()){//å¤ææ件ç®å½æ¯å¦åå¨
dir.mkdirs();
}
file = new File(filePath+"\\"+fileName); //æ°å»ºä¸ä¸ªfileç±»
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos); //è¾åºçbyteæ件
bos.write(bfile);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close(); //å
³éèµæº
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (fos != null) {
try {
fos.close(); //å
³éèµæº
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}