More info: http://java.sun.com/docs/books/tutorial/networking/urls/creatingUrls.html
On Feb 15, 11:29 am, ivanchan <[email protected]> wrote: > thanks all for the feedback, > > Usinguri= newURI("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= newURI("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 ofuriwhich get the orignal > error message. > Then I check the API again, it said it will throw > IllegalArgumentException ifuriis 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 (URIuri) > Since: API Level 1 > > public HttpGet (Stringuri) > Since: API Level 1 > > Throws > IllegalArgumentException if theuriis 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= newURI("http://" + path); > > > ...or... > > >uri= newURI("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

