将字节流(byte[])转换成文件
2011/12/9 9:40:01 hsyzijvaa http://hsyzijvaa.iteye.com
我要评论(0)
- 摘要:/***将字节流转换成文件*@paramfilename*@paramdata*@throwsException*/publicstaticvoidsaveFile(Stringfilename,byte[]data)throwsException{if(data!=null){Stringfilepath="D:\\"+filename;Filefile=newFile(filepath);if(file.exists()){file.delete();
- 标签:文件
/**
* 将字节流转换成文件
* @param filename
* @param data
* @throws Exception
*/
public static void saveFile(String filename,byte [] data)throws Exception{
if(data != null){
String filepath ="D:\\" + filename;
File file = new File(filepath);
if(file.exists()){
file.delete();
}
FileOutputStream fos = new FileOutputStream(file);
fos.write(data,0,data.length);
fos.flush();
fos.close();
}
}