i am geting NetworkOnMainThreadException while i am trying to read the text from a .txt file which is present on server how can i solve this problem
thanks in advance. 

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

        TextView tv= new TextView(this);
        TextView tv2 = 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();
        }
        catch (NetworkOnMainThreadException e){

            tv2.setText("not connecting to server");
            setContentView(tv2);
        }

    };        
    }

```