就是这句:
import com.smart.net.utils.NetTool;
难道是因为我还有什么包没安装吗?
import com.smart.net.utils.NetTool;
难道是因为我还有什么包没安装吗?
解决方案 »
- 请教一下我这种情况是自学好呢,还是去上培训班比较好
- 如何计算Android的应用的耗电量?
- ubuntu下载android内核源码连接出现问题
- android有一段TabHost的编码错误,有高手帮着调试一下吗?
- Build Target是2.2,为什么运行时候选1.6的仿真器也可以运行?
- Failed to install*.apk on device '': timeout
- 安卓陀螺仪数据问题。。不容易察觉的细节。
- (详情见图片)下载了所有版本的SDK,为什么在创建AVD模拟器时候target能选择3个版本,新人求解,谢谢
- android SoundPool播放没声音 还总是报SocketStream readFully错误
- 原型设计的网站
- 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里的一个类。应该不是系统的,你自己看看是用了这类里什么方法,不行自己写个呗