So I'm making an application to store shortcuts to all the user's favorite applications, acting kind of like a hub. I can have support for actual files and I have a .lnk
parser for shortcuts. I thought it would be pretty good for the application to support Internet shortcuts, too. This is what I'm doing:
Suppose I'm trying to get Google's icon (http://www.google.com/favicon.ico
).
I start out by getting rid of the extra pages (e.g.
www.google.com/anotherpage
would becomewww.google.com
.Then, I use
ImageIO.read(java.net.URL)
to get the Image.
The problem is that ImageIO
never returns an Image when I call this method:
String trimmed = getBaseURL(page); //This removes the extra pages
Image icon = null;
try {
String fullURLString = trimmed + "/favicon.ico";
URL faviconURL = new URL(fullURLString);
icon = ImageIO.read(faviconURL);
} catch (IOException e) {
e.printStackTrace();
}
return icon;
Now I have two questions:
- Does Java support the ICO format even though it is from Microsoft?
- Why does
ImageIO
fail to read from the URL?
Thank you in advance!
http://www.google.com/favicon.ico
. – BoogeymanURL(java.net.URL)
. How is that compiling for you? – Kristiankristiansandnew URL(fullURLString)
. I'll change that. – Boogeyman