Re: [Htmlparser-user] Malformed Input Exception
Brought to you by:
derrickoswald
From: Derrick O. <Der...@ro...> - 2003-02-27 02:54:12
|
If I recall correctly, implementing this feature would require deferring not only the connect but also the determination of the character set (from the header returned by the connect) and creation of the reader (because it needs the character set, and an input stream) until elements() is called. elements() would need to check for a null reader and do the work. Then getReader() and getEncoding() would also have to handle a null reader or null character_set too. Are there other subtleties? Maybe tricky, but probably do-able. I think all the constructors have test cases. But then, all that's really being saved is the user coding: Parser parser = new Parser ("http://yadda"); URL url = parser.getConnection (); ...process the url as appropriate ... parser.elements () instead of: URL url = new URL ("http://yadda"); url.openConnection (); ...process the url as appropriate Parser parser = new Parser (url); ... parser.elements () So it's probably not really worth the convoluted coding, unless I'm missing something in the use-case. Derrick htm...@li... wrote: > >Also, on another note, if I try to initialize the >parser directly, I am unable to work with the >URLConnection. For example: > > HttpURLConnection urlConn = null; > HTMLParser parser = new >HTMLParser("http://somedomain/somepath"); > urlConn = >(HttpURLConnection)parser.getConnection(); > urlConn.setDoInput(true); > // ... > >This code throws an exception because the HTTP request >has already been made. > >Exception in thread "main" >java.lang.IllegalAccessError: Already connected > at >java.net.URLConnection.setDoInput(URLConnection.java:677) > >--- Bob Lewis <bob...@ya...> wrote: > > <snip> > >--__--__-- > >Message: 3 >From: "Somik Raha" <so...@ya...> >To: <htm...@li...> >Subject: Re: [Htmlparser-user] Malformed Input Exception >Date: Tue, 25 Feb 2003 22:46:16 -0800 >Reply-To: htm...@li... > >That sounds like a good feature request. Derrick ->what do you think ? > >Regards, >Somik > > > > > > |