1.创建一个URL对象 url = new URL(urlString); 2.通过URL对象创建一个HttpURLConnection对象 HttpURLConnection urlConn = (HttpURLConnection)url.openConnection( ); 3.获得一个InputStream对象 urlConn.getInputStream( );字节流 InputStreamReader(urlConn.getInputStream());字符流 buff = new BufferedReader(newInputStreamReader(urlConn.getInputStream( )));buff可以读取一行数据 4.从InputStream中读取数据 5.访问网络的权限 <uses.premission android:premission="android.premission.INTENRNET"/> 访问SD卡 1.得到当前设备SD卡的目录 Environment.getExternalStorageDirectory() ; 返回外部储存设备的目录 2.访问SD卡的权限 <uses-permission android:permission="android.permission.WRITE_EXTERNAL_STORAGE"/>
|