将字节流byte[]转换成成文件

来源:互联网 发布:js json push 编辑:程序博客网 时间:2024/05/24 07:23
public File operaFileData(String path, byte[] by)
{
{
FileOutputStream fileout = null;
String fileName = path + "baidu.apk";
File file = new File(fileName);
if (file.exists())
{
file.delete();
}
try
{
fileout = new FileOutputStream(file);
fileout.write(by, 0, by.length);

} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} finally
{
try
{
fileout.close();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

return file;
}

}

原创粉丝点击