可能重复:
从字节数组创建文件
大家好我有一个问题我有一个字节数组,里面有一个文件.doc 我需要将此字节数组转换为 java.io.File 谁可以发布一段执行我请求的 Java 代码?谢谢大家
Use file output stream:
FileOutputStream fos = new FileOutputStream("filename");
fos.write(byteArray);
fos.close();
Create a ByteOutputStream with your binary representation, and then:
OutputStream outputStream = new FileOutputStream ("c:\\a.doc");
byteArrayOutputStream.writeTo(outputStream);
byteArrayOutputStream.close();
I think it will be enough
Hope this helps