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. calling activity from menu

Hi,

I have a menu item which when selected would call another activity
class. I am using switch case to select between menu items. I tried
creating an Intent to start activity using the Class name but doesn't
work.

please help.

Thanks,
mithun

-- 

2. Garmin for Android

Ini hanya buat ujicoba untuk mengurangi rasa penasaran saya.

Mohon untuk tidak meminta file atau cara instalasi Garmin-nya di Android
-smile-

 

Bisa diakses menggunakan System recovery Mode.

Tool lain bisa menggunakan Astro (ada di market).

Untuk Garmin Asus bisa tekan+tahan tombol atas lalu tekan power.

 

File yang diperlukan untuk dicopy:

/storage/.system => semua file, peta & JCV ada disini

/system/app/com.garmin.android.apps.search.city.odex

/system/app/com.garmin.android.apps.subscription.apk

/system/app/com.garmin.android.apps.search.coordinates.apk

/system/app/GarminLocate.apk

/system/app/GarminEnglishIME.odex

/system/app/GarminService.apk

/system/app/GarminOnlineProvider.odex

/system/app/GarminEnglishIME.app

/system/app/com.garmin.android.apps.converter.apk

/system/app/com.garmin.android.apps.converter.odex

/system/app/GarminGarage.odex

/system/app/GarminSoftKeyboardSettings.apk

/system/app/com.garmin.android.apps.subscription.odex

/system/app/com.garmin.android.apps.location.odex

/system/app/GarminSoftKeyboardSettings.odex

/system/app/com.garmin.android.apps.safetycameras.apk

/system/app/com.garmin.android.apps.weather.apk

/system/app/GarminOnlineProvider.apk

/system/app/GarminService.odex

/system/app/com.garmin.android.apps.search.city.apk

/system/app/com.garmin.android.apps.localsearch.apk

/system/app/com.garmin.android.apps.localsearch.odex

/system/app/com.garmin.android.apps.weather.odex

/system/app/com.garmin.android.apps.search.coordinates.odex

/system/app/com.garmin.android.apps.search.poi.apk

/system/app/com.garmin.android.apps.search.poi.odex

/system/app/com.garmin.android.apps.safetycameras.odex

/system/app/com.garmin.android.apps.location.apk

/system/app/com.garmin.android.apps.search.upcomingevents.odex

/system/app/com.garmin.android.apps.search.upcomingevents.apk

/system/app/GarminLocate.odex

/system/app/GarminGarage.apk

/system/framework/com.garmin.android.search.jar

/system/framework/com.garmin.android.search.odex

/system/framework/com.garmin.android.location.jar

/system/framework/com.garmin.android.location.odex

/system/framework/com.garmin.android.inputmethodservice.jar

/system/framework/com.garmin.android.inputmethodservice.odex

/system/framework/com.garmin.android.cld.jar

/system/framework/com.garmin.android.cld.odex

/system/framework/com.garmin.android.gal.jar

/system/framework/com.garmin.android.gal.odex

/system/framework/com.garmin.android.util.jar

/system/framework/com.garmin.android.util.odex

/system/framework/com.garmin.android.widget.jar

/system/lib/libgarmincal.so

/system/script/app/GarminGarage.bsh

/system/script/mtbf/MTBF_Garmin_Connected_start.bsh

/system/script/mtbf/MTBF_Garmin_Navigation_start.bsh

/system/script/mtbf/MTBF_Garmin_Misc_start.bsh

/system/script/mtbf/MTBF_Garmin_start.bsh

/system/bin/garminos

/system/bin/garminos-ctl

/system/etc/permissions/com.garmin.android.search.xml

/system/etc/permissions/com.garmin.android.inputmethodservice.xml

/system/framework/com.garmin.android.widgetodex

 

Thank You in Advance

 

Gunaris

 <http://www.otomasi.com> www.otomasi.com

08999993655 / 081280338888, skype/YM: otomasi1

 

-- 
===============
"

3. What happens with activity when i press BACK key on device?

4. Calling onUpdate() from onReceive() in AppWidgetProvider

5. android access to ringtones list in settings

6. Sliding drawer Implementation through java code

7. Calling activity from Stub