I wanted to save image to user machine while he is launching my java application. for this i have written code as follows :
BufferedImage image = null;
try {
URL url = new URL(logourl);
image = ImageIO.read(url);
ImageIO.write(image, "png",new File("/usr/swa.png"));
} catch (IOException e) {
e.printStackTrace();
}
But it is giving me
java.io.FileNotFoundException: /usr/swa.png (Permission denied)
but if i used
ImageIO.write(image, "png",new File("/home/MyUserName/Desktop/applicationName/logo.png"));
Then it saving the image.
i dont get why it is not accessing that path if it working for /home/MyUserName/Desktop/applicationName/logo.png
this path.
basically when user install application i want fetch image from web url and save it to user's local machine so what i need to to achieve this??
EDIT : Exception corrected