I’m trying to save an image using a JFileChooser. I only want the user to be able to save the image as a jpg. However if they don’t type .jpg it wont be saved as an image. Is it possible to somehow append “.jpg” to the end of the file?
File file = chooser.getSelectedFile() + ".jpg";
Doesn’t work as I’m adding a string to a file.
Why not convert the
Fileto aStringand create a newFilewhen you’re done?Remember, you don’t need to add the
.jpgif it’s already there.