I have a byte array, i want to create an image file(bmp file) of byte array. I create an images folder in src (my path is src/images/test.bmp). my code is in below, in
OutputStream stream = new FileOutputStream(file);
i get error. what is my problem? How can i solve this?
public static void saveImage() {
String s="........................";
byte[] dataCustImg = Base64.decode(s.getBytes());
File file = new File("/images/test.bmp");
if (file.exists()) {
file.delete();
}
file = new File("/images/test.bmp");
file.mkdirs();
try {
OutputStream stream = new FileOutputStream(file);
stream.write(dataCustImg);
stream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Error:
java.io.FileNotFoundException: \images\test.bmp (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)