StringIndexOutOfBoundsException when calling ava.net.URL.openStream

by manigault » Mon, 04 Apr 2011 21:40:35 GMT


Sponsored Links
 Hi all,
I faced really nasty problem these days. I am executing the following
code


    String destination = "";// this string is initialized before
coming here


    URL url = null;
    InputStream inputStream = null;
    try {
        url = new URL(destination);
        inputStream = url.openStream();
        // process the input stream
    catch (IOException e) {
        // handle the exception
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
    }


This was working fine so far, but i start to receive to following
exception -


    Exception: java.lang.StringIndexOutOfBoundsException
    Stack Trace :
    java.lang.String.substring(String.java:1579)
 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getAuthorizationCredentials(HttpURLConnectionImpl.java:
1769)
 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequestInternal(HttpURLConnectionImpl.java:
1701)
 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequest(HttpURLConnectionImpl.java:
1649)
 
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:
1153)
    java.net.URL.openStream(URL.java:653)

I can't figure out for which values of 'destination' this exception is
thrown but i think this should never happen. The doc says the
openStream could throw only IOException. Any ideas ?

-- 



Re: StringIndexOutOfBoundsException when calling ava.net.URL.openStream

by Daniel Drozdzewski » Mon, 04 Apr 2011 22:04:36 GMT


 What does destination String equal to?
have you changed it recently?








-- 
Daniel Drozdzewski

-- 


Sponsored Links


Re: StringIndexOutOfBoundsException when calling ava.net.URL.openStream

by Martin Obreshkov » Mon, 04 Apr 2011 22:57:53 GMT


 No destination is dynamically returned by other request to the server.
Basically i am a server which returns a list of urls which i am processing
in a for loop using this code. The server is querying a search engine and
returns urls which content mach the desired search.

On Mon, Apr 4, 2011 at 5:04 PM, Daniel Drozdzewski <








-- 
When I raise my flashing sword, and my hand takes hold on judgment, I will
take vengeance upon mine enemies, and I will repay those who haze me. Oh,
Lord, raise me to Thy right hand and count me among Thy saints.

-- 



Re: StringIndexOutOfBoundsException when calling ava.net.URL.openStream

by Kostya Vasilyev » Tue, 05 Apr 2011 00:07:38 GMT


 The top-level function you're calling should indeed only throw those
exceptions that are specified in its signature. But if it calls other
classes / methods, there could be all kinds of exceptions, including runtime
errors (like the one you are facing). The former would be caught and
eventualy rethrown as specified by the top-level method,  the latter can
lead to crashes.

I'd recommend you track down the source for your device's version of
HttpURLConnectionImpl.java, and take a look at the method mentioned in the
crash.

-- Kostya

2011/4/4 manigault <manig...@gmail.com>


-- 



Other Threads

1. mohon bantuan update frf91 di nexus one

salam buat para suhu dan temen2
saya dah 2 kali dapat info update dari google dan selalu gagal updatenya
kondisi rom saya pake frf50 yg signed with radio.
saya dah download frf91 tapi selalu gagal waktu updatenya
saya mohon bantuan link utk frf91.., serta petunjuknya.
mohon mohon mohon

-- 
"Indonesian Android Community [id-android]" 

2. How to detect the end of a scroll

Hi all,
I am using a HorizontalScrollView, I would like to detect when ever my
scrollbar reaches its end, I know that there is onscrolllistener for
listview , I want a similar kind of thing for any kind of view. Any
insight will be really helpfull

Regards
Dantu

-- 

3. does the backup service on Froyo backup the data of a specific user

4. Disable the screen lock when the Android OS startup

5. CTS install_failed_insufficient_storage error

6. Starting the emulator in QVGA screen size produces a skewded DatePicker in default Android settings

7. android 2.2 Cloud to Device Messaging