Új hozzászólás Aktív témák

  • domel

    tag

    Üdv! Szeretnék egy text fájlot letölteni az internetről egy string típusú változóba, minden fórumon ezt ajánlják:

    public void fafa(View view) {

    try {
    // Create a URL for the desired page
    URL url = new URL("http://www.spessart.hu/counter.txt");

    // Read all the text returned by the server
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String str;
    while ((str = in.readLine()) != null)
    {
    // str is one line of text; readLine() strips the newline character(s)
    }
    in.close();
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    }

    }

    de nekem hibaüzenet nélkül elszáll tőle a program (a telefonon).

    Mi lehet a hiba? Van esetleg valakinek működő kódja? Megköszönném! :)

    Üdv: Domel

Új hozzászólás Aktív témák