为什么错误了

为什么异常了
使用下面这个获取数据的方法发生异常,怎么回事?请大家帮忙看看,连了网。
Java code

public static InputStream getRequest(String path) throws Exception {

            URL url = new URL(path);

            HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            conn.setRequestMethod("GET");

            conn.setConnectTimeout(5000);

            if (conn.getResponseCode() == 200){

                    return conn.getInputStream();

            }

            return null;

    }



------解决方案--------------------
布局setContentView呢
------解决方案--------------------
你没setContentView。。。
------解决方案--------------------
<uses-permission android:name="android.permission.INTERNET"/>
这个权限加上了吗