thanks all for the feedback,
Using uri = new URI("http", "finance.yahoo.com", "/q/hp?s=^DJI",
""); ,
I got 404 not found,
Using path = URLEncoder.encode("finance.yahoo.com/q/hp?s=^DJI",
"UTF-8");
uri = new URI("http://" + path);
I got E/AndroidRuntime( 311): Caused by:
java.lang.IllegalArgumentException: Host nam
e may not be null
,
Previously, I just use a string instead of uri which get the orignal
error message.
Then I check the API again, it said it will throw
IllegalArgumentException if uri is invalid anyway.
Sorry I am new to Java, if the design will throw this exception, what
should I do to resolve it?
public HttpGet ()
Since: API Level 1
public HttpGet (URI uri)
Since: API Level 1
public HttpGet (String uri)
Since: API Level 1
Throws
IllegalArgumentException if the uri is invalid.
Regards,
Ivan
On 2月15日, 上午6時48分, -DC- <[email protected]> wrote:
> How are you creating the URL? Try one of these methods:
>
> path = URLEncoder.encode("finance.yahoo.com/q/hp?s=^DJI", "UTF-8");
> uri = new URI("http://" + path);
>
> ...or...
>
> uri = new URI("http", "finance.yahoo.com", "/q/hp?s=^DJI", "");
>
> On Feb 13, 11:55 pm, ivanchan <[email protected]> wrote:
>
> > Hi all,
>
> > I am trying to use HttpGet to fetch some data from yahoo finace, the
> > whole url is
> > "http://finance.yahoo.com/q/hp?s=^DJI", from the log I gucess it
> > complains
> > about the '^' character, what is the right way to solve this problem?
> > Thanks.
>
> > E/AndroidRuntime( 287): java.lang.IllegalArgumentException: Illegal
> > character i
> > n query at index 32:http://finance.yahoo.com/q/hp?s=^DJI
> > E/AndroidRuntime( 287): at java.net.URI.create(URI.java:970)
> > E/AndroidRuntime( 287): at
> > org.apache.http.client.methods.HttpGet.<init>
> > (HttpGet.java:75)
> > E/AndroidRuntime( 287): at
> > Ivan.stock.droid.HttpHelper.connect(HttpHelpe
>
> > Regards,
> > Ivan
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en