粘贴下面方法直接调用即可
public File getFileFromBytes(byte[] b, String outputFile) {
BufferedOutputStream stream = null;
File file = null;
try {
file = new File(outputFile);
FileOutputStream fstream = new FileOutputStream(file);
stream = new BufferedOutputStream(fstream);
stream.write(b);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (stream != null) {
try {
stream.flush();
stream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
return file;
}
方法调用如下路径不需要权限
String s = getExternalFilesDir("66").getAbsolutePath();
getFileFromBytes(bytes, s + System.currentTimeMillis() + ".jpg");