Did you try looking at the documentation for
java.awt.Toolkit? The Toolkit.getImage(
String) method takes the name of a file. Not a url. The Toolkit.getImage(java.net.URL) method is appropriate what you are trying to do.
When you were having problems with InputStream.available(), did you try looking at the
documentation? If you did, you'd see that available() doesn't return the file size, it returns ". . . the number of bytes that can be read (or skipped over) from this input stream without blocking".