hi ,
i am trying to read text from a .txt file which is present on server
but my code is not reading text from file i am using android version
2.1 . thanks in advance


public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TextView tv= new TextView(this);
        StringBuilder content = new StringBuilder();


        try {
            URL url = new URL("http://linktomywebsite/textfile.txt";);
            BufferedReader in = new BufferedReader(new
InputStreamReader(url.openStream()));
            String str;
            while ((str = in.readLine()) != null) {
                content.append(str +"\n");
                tv.setText(content);
            }
            in.close();
        } catch (MalformedURLException e){
        } catch (IOException e) {
            e.printStackTrace();
        }


    };

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to