×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    2

    openinputstream() returns null

    I try to run my first application using web access. Upon execution, N 6021 asks for network connection (I think this is on the Connector.open()) call,

    Connector.open() returns a valid object, the casting to HttpConnection works fine
    A nullpointerexception is thrown between the two textbox calls

    I suspect a bug, or perhaps wrong configuration (however browser works fine)

    Note, I am using gsm-data, not gprs for network communication.

    Anybody used gsm-data communication for an applet with N 6021 ?

    Here is the code extracts

    protected void startApp() throws MIDletStateChangeException {
    System.out.println("StartApp called");
    try
    {
    downloadPage("http://www.javacourses.com/hello.txt");
    }
    catch(IOException e)
    {
    textbox.setString(textbox.getString()+"\nIOException");
    display.setCurrent(textbox);
    }
    catch(NullPointerException ne){
    textbox.setString(textbox.getString()+"\nNullPointerException");
    display.setCurrent(textbox);
    };
    }

    private void downloadPage(String url) throws IOException {
    StringBuffer b = new StringBuffer();
    InputStream is = null;
    HttpConnection c = null;
    TextBox t = null;
    try {
    long len = 0 ;
    int ch = 0;

    c = (HttpConnection)Connector.open(url);
    textbox.setString(textbox.getString()+"\nc="+c);
    display.setCurrent(textbox);
    c.setRequestMethod(HttpConnection.GET);
    is = c.openInputStream();
    textbox.setString(textbox.getString()+"\nis="+is);

    ...

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: openinputstream() returns null

    It seems like your textbox object is null, or the getString() method returns null ?

    You should not catch NullPointerException, as it is only thrown if you are trying to call a method (or accessing a variable) on a null object, that is, you can prevent that from happening just by checking if a particular object is null before using it.

    Daniel

Similar Threads

  1. Please its veru urgent on nokia 3250
    By siva_guduru in forum Mobile Java General
    Replies: 8
    Last Post: 2008-05-01, 10:24
  2. Replies: 1
    Last Post: 2005-12-20, 18:45
  3. conn = (MessageConnection)Connector.open(smsc); returns null
    By JWtheCoolOne in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2005-01-11, 09:30
  4. global root overflow(please help)
    By sushant_125 in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2004-05-14, 08:24
  5. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×