就是这句:
import com.smart.net.utils.NetTool;
难道是因为我还有什么包没安装吗?
import com.smart.net.utils.NetTool;
难道是因为我还有什么包没安装吗?
解决方案 »
- 如何调用系统中原有的闹钟铃声?
- android 录音问题 !!急!!!!!!!!
- 项目(求教育)打包成apk了,assets目录还能不能改变?(一个看似很简单的问题)
- 有人做过效果比较拉轰的滚动字幕木有?
- android中的logcat调试问题
- 想开发个android浏览器,需要研究哪些技术
- 从网上加载图片,老是报OutOfMemoryError,如何解决?
- Android 百度地图自定义线路问题
- android frameoworks/base/core/res/res/config.xml
- Tread.run 对于大量数据的解析
- android 高难度UI设计问题!!!!
- 怎么让程序在屏幕锁定后保存起来,然后屏幕解锁的时候继续运行
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;public class NetTool {
/**
* 获得url代码数据
* */public static String getHtml(String path,String encoding) throws Exception {
URL url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(6 * 1000);
// 别超过10秒。
System.out.println(conn.getResponseCode());
if(conn.getResponseCode()==200){
InputStream inputStream=conn.getInputStream();
byte[] data=readStream(inputStream);
return new String(data,encoding);
}
return null;
}/**
* 获取指定路径,的数据。
*
* **/
public static byte[] getImage(String urlpath) throws Exception {
URL url = new URL(urlpath);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(6 * 1000);
// 别超过10秒。
if(conn.getResponseCode()==200){
InputStream inputStream=conn.getInputStream();
return readStream(inputStream);
}
return null;
}/**
* 读取数据
* 输入流
*
* */
public static byte[] readStream(InputStream inStream) throws Exception {
ByteArrayOutputStream outstream=new ByteArrayOutputStream();
byte[] buffer=new byte[1024];
int len=-1;
while((len=inStream.read(buffer)) !=-1){
outstream.write(buffer, 0, len);
}
outstream.close();
inStream.close();
return outstream.toByteArray();
}
}
http://www.cnblogs.com/llb988/archive/2011/02/11/1951693.html
你看的是不是这个啊,那应该是人家自己写的demo里的一个类。应该不是系统的,你自己看看是用了这类里什么方法,不行自己写个呗