Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

What are the java supported image file formats?

843804Jul 15 2005 — edited Jul 19 2005
i need info of types of images supported by java.

Comments

843834
OK, I figured out that I needed to parse the DataInputStream.... so:
try {
            u = new URL("http://www.google.com"); 
            is = u.openStream(); 
            dis = new DataInputStream(new BufferedInputStream(is)); 
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            docBuilderFactory.setIgnoringComments(true);
            docBuilderFactory.setValidating(false);
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            Document doc = docBuilder.parse(dis);  // The exception is caught here.....

        } catch (Exception ex) {
               System.out.println(ex.getMessage());
         }
But now I get this exception:
class org.xml.sax.SAXParseException
The entity name must immediately follow the '&' in the entity reference.

Any idea?
843834
Or in other words...

What is the best way to parse a URL and ignore all SAXParseException.
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse("http://www.gogle.com");
Thanks.
DrClap
n_k wrote:
What is the best way to parse a URL and ignore all SAXParseException.
The best way is to not use an XML parser. XML parsers are required to throw an exception and stop parsing as soon as they encounter malformed XML.

And since (according to your example) you're trying to parse HTML, you would be better off to use an HTML parser that produces a DOM.
843834
Thanks.

I used the html parser (http://htmlparser.sourceforge.net/) and it works fine.
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 16 2005
Added on Jul 15 2005
4 comments
161 views