1. Download our Official Android App: Forums for Android!

Apps Problem accessing web page

Discussion in 'Android Development' started by shadowy, Mar 20, 2011.

  1. shadowy

    shadowy Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    25
    Joined:
    Sep 30, 2010

    Sep 30, 2010
    25
    2
    16
    I'm having problems accessing a particular web page. If I try e.g. Humber Squash - humbersquash.org - Results it works fine, but with Humber Squash - humbersquash.org - The Clubs I get a java.io.FileNotFoundException. Is there any reason why a .html should need processing differently to a .asp? This is the code:

    public static String getData(String url, String post) {

    String pageContent="";

    try

    {

    URL myUrl = new URL(url);

    HttpURLConnection myConnection = null;

    myConnection = (HttpURLConnection)myUrl.openConnection();

    myConnection.setDoOutput(true);

    OutputStreamWriter wr = new OutputStreamWriter(myConnection.getOutputStream());

    if (post != "") {

    wr.write(post);

    wr.flush();

    };

    InputStream in = myConnection.getInputStream();

    StringBuffer myStringBuffer = new StringBuffer();

    int b;

    while ((b = in.read()) != -1)

    {

    myStringBuffer.append((char)b);

    }

    pageContent=myStringBuffer.toString();

    wr.close();

    in.close();

    }
    catch(Throwable e)

    {

    System.out.println("*****Web error " + e);


    }

    return pageContent;
    }
     

    Advertisement

Share This Page

Loading...