易截截图软件、单文件、免安装、纯绿色、仅160KB

JAVA 爬网页用 例如:http://www.126.com

/*
Function name: myGetHttpFile2
Description: 爬网页用
Input: URL 例如:http://www.126.com
Output: 字符串,网页的HTML
*/
public String myGetHttpFile2(String url){
String authentication=null;
ArrayList al=new ArrayList();
String PageURL = url;
PageURL = url ;
ArrayList urlCollection=new ArrayList();
Hashtable ht=new Hashtable();
//代理,如果要穿过代理将下面注释取消
//ht=System.getProperties();
//authentication = "Basic " + new sun.misc.BASE64Encoder().encode("代理的用户:代理的密码".getBytes());
//ht.put("proxySet", "true");
//ht.put("proxyHost", "172.16.20.2");
//ht.put("proxyPort", "80");

String urlSource=PageURL;
StringBuffer htmlBuffer=new StringBuffer();
String returnStr=null;
int codeStart=0;
int codeEnd=0;
int linkCount=0;

String getURL=null;
String realURL=null;
String urlText=null;
int from=0;
int lenURL=0;
int firstLink=0;
int endLink=0;
boolean isNewsLink=false;

try
{
URL su = new URL (urlSource);
URLConnection conn = su.openConnection();
//conn.setRequestProperty("Proxy-Authorization", authentication);

InputStream imageSource=new URL(urlSource).openStream();
int ch;
while((ch=imageSource.read())>-1)
{
htmlBuffer.append((char)ch);
}
imageSource.close();
returnStr= new String(htmlBuffer);
returnStr=new String(returnStr.getBytes("ISO8859_1"),"GBK");
}
catch(Exception e)
{
}

if(returnStr!=null){
return returnStr ;
}else{
return "empty" ;
}

}



相关文档:

java classLoader 体系结构

jvm classLoader architecture:
1. Bootstrap ClassLoader/启动类加载器
主要负责jdk_home/lib目录下的核心 api 或 -Xbootclasspath 选项指定的jar包装入工作。
2. Extension ClassLoader/扩展类加载器
主要负责jdk_home/lib/ext目录下的jar包或 -Djava.ext.dirs 指定目录下的jar包装入工作。
3 ......

Java ClassLoader 分析

先贴一段
Java
基本结构
Java
结构包括四个不同而又相关的部分:
Java
语言、
class
文件格式、应用程序接
口、虚拟机
其中,虚拟机的主要任务是在程序运行中需要的时候调用
class
文件并执行其中的字节码。一个
Java

用有两种
class loader

the system class loader

class loader objects ......

java 事物


一、什么是Java事务
  通常的观念认为,事务仅与数据库相关。
  事务必须服从ISO/IEC所制定的ACID原则。ACID是原子性(atomicity)、一致性(consistency)、隔离性(isolation)和持久性(durability)的缩写。事务的原子性表示事务执行过程中的任何失败都将导致事务所做的任何修改失效。一致性表示当事务执行失败 ......

Java中的字符串鼠标和键盘事件

字符串
1、获取字符串的长度 
length() 
2 、判断字符串的前缀或后缀与已知字符串是否相同 
前缀 startsWith(String s) 
后缀 endsWith(String s) 
3、比较两个字符串 
equals(String s) 
4、把字符串转化为相应的数值 
int型 Integer.parseInt(字符串) 
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号