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. CTS and frameword modifications

Hi all,

I'm porting Android to a particular board and I have some questions.

First, Can we implements just 50 % of a fonctionality. For exemple, in the
framework there is a Class that contain a method  public String
myFunction(){  //frameword Code}. Can I change it for public static String
myFunction(){ return "");}?

Finally, a question more complex, can I make my own implementation of an
Interface a pass it in a framework factory decorated with @hide. Exemple :

@hide
public class MyFactory{

     public InterfaceC getAObject(){
        return (InterfaceC) new A();
     }

     public InterfaceC getBObject(){
       return (InterfaceC) new B();
     }
}

A and B implement InterfaceC.
Factory is a framework class in android package.


Can I write something like

public class MyFactory{

     public InterfaceC getAObject(){
        return (InterfaceC) new D();
     }

     public InterfaceC getBObject(){
       return (InterfaceC) new D();
     }
}

D implements InterfaceC.

Do this two modification are CTS compliant?


Thanks,
Adrien

-- 

2. SIP

I think it's a little off-topic, but if someone has some experience
with it and could give me some help I appreciate.

I need a SIP softphone to run on Android with zRTP protocol.
I found CSipSimple, an open-source, C software.
In my tests works fine, but I need one built on Java.

Thanks.

-- 

3. Sip Communicator

4. Double lifecycle sequence from landscape to portrait

5. Can Android be ported to Samsung Corby Pro?

6. Layout help

7. getSharedPreferences for a wallpaper