Reading an image from a file
suggest changeimport java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
...
try {
Image img = ImageIO.read(new File("~/Desktop/cat.png"));
} catch (IOException e) {
e.printStackTrace();
}
A File built from "~/Desktop/cat.png" does not expand ~; that character is a literal path segment.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents