新版HttpClient4.2与之前的3.x版本有了很大变化,建议从http://hc.apache.org/处以得到最新的信息。

  1. 关于HttpCore与HttpClient:HttpCore是位于HTTP传输组件的底层包,可以用来简化HTTP客户端与服务器端的开发。HttpClient是一个符合HTTP1.1版本,基于HttpCore类包的一个实现。它同时为客户端认证、HTTP状态管理、HTTP连接管理提供了可重用的客户端组件。HttpCore类包目前最新发布版本是httpcore-4.2.4;HttpClient类包的版本是httpclient-4.2.5。
    了解到HttpCore包与HttpClient包的差别,在程序中就应该大致知道一些包它们存在于哪个类库中。比如:org.apache.http包属于HttpCore,而org.apache.http.client包属于HttpClient。
  2. HttpClient的API文档在下载的zip中已经包括;
    HttpCore的API文档可以参考:http://hc.apache.org/httpcomponents-core-4.2.x/httpcore/apidocs/index.html
  3. HttpClient4.2需要Java 5.0及以上版本;需要支持包有(下载zip包中已经包括):
    * Apache HttpComponents HttpCore
    * Apache Commons Logging
    * Apache Commons Codec

1. 获取一个HTML页面的内容,一个简单的get应用

    // 获取一个HTML页面的内容,一个简单的get应用
public void grabPageHTML() throws Exception {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://www.baidu.com/");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
String html = EntityUtils.toString(entity, "GBK"); // releaseConnection等同于reset,作用是重置request状态位,为下次使用做好准备。
// 其实就是用一个HttpGet获取多个页面的情况下有效果;否则可以忽略此方法。
httpget.releaseConnection(); System.out.println(html);
}

2. 下载一个文件到本地(本示范中为一个验证码图片)

    // 下载一个文件到本地(本示范中为一个验证码图片)
public void downloadFile() throws Exception {
String url = "http://www.lashou.com/account/captcha";
String destfilename = "D:\\TDDOWNLOAD\\yz.png";
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
File file = new File(destfilename);
if (file.exists()) {
file.delete();
} HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
try {
FileOutputStream fout = new FileOutputStream(file);
int l = -1;
byte[] tmp = new byte[2048];
while ((l = in.read(tmp)) != -1) {
fout.write(tmp);
}
fout.close();
} finally {
// 在用InputStream处理HttpEntity时,切记要关闭低层流。
in.close();
} httpget.releaseConnection();
}

3. Post方法,模拟表单提交参数登录到网站并打开会员页面获取内容(会话保持)

    // Post方法,模拟表单提交参数登录到网站。
// 结合了上面两个方法:grabPageHTML/downloadFile,同时增加了Post的代码。
public void login2Lashou() throws Exception {
// 第一步:先下载验证码到本地
String url = "http://www.lashou.com/account/captcha";
String destfilename = "D:\\TDDOWNLOAD\\yz.png";
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
File file = new File(destfilename);
if (file.exists()) {
file.delete();
} HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
try {
FileOutputStream fout = new FileOutputStream(file);
int l = -1;
byte[] tmp = new byte[2048];
while ((l = in.read(tmp)) != -1) {
fout.write(tmp);
}
fout.close();
} finally {
in.close();
}
httpget.releaseConnection();


// 第二步:用Post方法带若干参数尝试登录,需要手工输入下载验证码中显示的字母、数字
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入下载下来的验证码中显示的数字...");
String yan = br.readLine(); HttpPost httppost = new HttpPost("http://www.lashou.com/account/login/");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("user_id", "testuser007"));
params.add(new BasicNameValuePair("pwd", "asdfg123"));
params.add(new BasicNameValuePair("yan", yan));
params.add(new BasicNameValuePair("save_user", "on"));
params.add(new BasicNameValuePair("save_pwd", "on"));
params.add(new BasicNameValuePair("sub", "登录"));
httppost.setEntity(new UrlEncodedFormEntity(params)); response = httpclient.execute(httppost);
entity = response.getEntity();
// 在这里可以用Jsoup之类的工具对返回结果进行分析,以判断登录是否成功
String postResult = EntityUtils.toString(entity, "GBK");
// 我们这里只是简单的打印出当前Cookie值以判断登录是否成功。
List<Cookie> cookies = ((AbstractHttpClient)httpclient).getCookieStore().getCookies();
for(Cookie cookie: cookies)
System.out.println(cookie);
httppost.releaseConnection();


// 第三步:打开会员页面以判断登录成功(未登录用户是打不开会员页面的)
String memberpage = "http://www.lashou.com/account/orders/";
httpget = new HttpGet(memberpage);
response = httpclient.execute(httpget); // 必须是同一个HttpClient!
entity = response.getEntity();
String html = EntityUtils.toString(entity, "GBK");
httpget.releaseConnection(); System.out.println(html);
}

输出:

请输入下载下来的验证码中显示的数字...
sbzq
...

[version: 0][name: login_name2][value: testuser007][domain: www.lashou.com][path: /][expiry: Mon Sep 09 10:21:19 CST 2013]
[version: 0][name: pwd2][value: 4c88a4062736c26572d3ec382868fa2b][domain: lashou.com][path: /][expiry: Mon Sep 09 10:21:19 CST 2013]
?<!doctype html>

...

4. 设置代理服务器

    // 设置代理服务器
public void testProxy() throws Exception {
HttpHost proxy = new HttpHost("127.0.0.1", 8888); // 方式一
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); // 方式二
HttpParams params = new BasicHttpParams();
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
HttpClient httpclient1 = new DefaultHttpClient(params);
}

5. 几种常用HTTP头的设置

    // 几种常用HTTP头的设置
public void testBasicHeader() throws Exception {
HttpParams params = new BasicHttpParams();
Collection<BasicHeader> collection = new ArrayList<BasicHeader>();
collection.add(new BasicHeader("Accept", "text/html, application/xhtml+xml, */*"));
collection.add(new BasicHeader("Referer", "http://www.sina.com/"));
collection.add(new BasicHeader("Accept-Language", "zh-CN"));
collection.add(new BasicHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"));
collection.add(new BasicHeader("Accept-Encoding", "gzip, deflate"));
params.setParameter(ClientPNames.DEFAULT_HEADERS, collection); HttpClient httpclient = new DefaultHttpClient(params); // 下面内容略
}

6. 多线程编程下的线程池设置

    // 多线程编程下的线程池设置(这点在需要登录且用一个HttpClient对象抓取多个页面的情况下特别有用)
public void testConnectionManager() throws Exception {
// 连接池设置
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
cm.setMaxTotal(200); // 连接池里的最大连接数
cm.setDefaultMaxPerRoute(20); // 每个路由的默认最大连接数
HttpHost localhost = new HttpHost("locahost", 80); // 可以针对某特定网站指定最大连接数
cm.setMaxPerRoute(new HttpRoute(localhost), 30); // 其它设置
HttpParams params = new BasicHttpParams();
params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
HttpClient httpclient = new DefaultHttpClient(cm, params); // 下面内容略
}

7. 测试HTTP上下文对象(HttpContext)

    // 测试HTTP上下文对象(HttpContext)
public void testContext() throws Exception {
// 请求一个页面,然后解析各上下文对象
DefaultHttpClient httpclient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext();
HttpGet httpget = new HttpGet("http://www.baidu.com/"); HttpResponse response = httpclient.execute(httpget, localContext); // the actual connection to the target server.
HttpConnection conn = (HttpConnection) localContext.getAttribute(
ExecutionContext.HTTP_CONNECTION);
System.out.println("Socket timeout: " + conn.getSocketTimeout()); // the connection target
HttpHost target = (HttpHost) localContext.getAttribute(
ExecutionContext.HTTP_TARGET_HOST);
System.out.println("Final target: " + target); // the connection proxy, if used
HttpHost proxy = (HttpHost) localContext
.getAttribute(ExecutionContext.HTTP_PROXY_HOST);
if (proxy != null)
System.out.println("Proxy host/port: " + proxy.getHostName() + "/"
+ proxy.getPort()); // the actual HTTP request
HttpRequest request = (HttpRequest) localContext
.getAttribute(ExecutionContext.HTTP_REQUEST);
System.out.println("HTTP version: " + request.getProtocolVersion());
Header[] headers = request.getAllHeaders();
System.out.println("HTTP Headers: ");
for (Header header : headers) {
System.out.println("\t" + header.getName() + ": " + header.getValue());
}
System.out.println("HTTP URI: " + request.getRequestLine().getUri()); // the actual HTTP response
response = (HttpResponse) localContext
.getAttribute(ExecutionContext.HTTP_RESPONSE);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println("Content Encoding:" + entity.getContentEncoding());
System.out.println("Content Type:" + entity.getContentType());
} // the flag indicating whether the actual request has been fully transmitted to the connection target.
System.out.println("Sent flag: " + localContext.getAttribute(ExecutionContext.HTTP_REQ_SENT));


// 如果没有用到返回entity中的内容,那么要把它消费掉,以保证底层的资源得以释放。
entity = response.getEntity();
EntityUtils.consume(entity);
}

输出:

Socket timeout: 0
Final target: http://www.baidu.com
HTTP version: HTTP/1.1
HTTP Headers:
    Host: www.baidu.com
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.2.5 (java 1.5)
HTTP URI: /
Content Encoding:null
Content Type:Content-Type: text/html;charset=utf-8
Sent flag: true

8. 完整的代码

package com.clzhang.sample.net;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import org.apache.http.Header;
import org.apache.http.HttpConnection;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils; public class HttpClientSample1 { // 获取一个HTML页面的内容,一个简单的get应用
public void grabPageHTML() throws Exception {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://www.baidu.com/");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
String html = EntityUtils.toString(entity, "GBK"); // releaseConnection等同于reset,作用是重置request状态位,为下次使用做好准备。
// 其实就是用一个HttpGet获取多个页面的情况下有效果;否则可以忽略此方法。
httpget.releaseConnection(); System.out.println(html);
} // 下载一个文件到本地(本示范中为一个验证码图片)
public void downloadFile() throws Exception {
String url = "http://www.lashou.com/account/captcha";
String destfilename = "D:\\TDDOWNLOAD\\yz.png";
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
File file = new File(destfilename);
if (file.exists()) {
file.delete();
} HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
try {
FileOutputStream fout = new FileOutputStream(file);
int l = -1;
byte[] tmp = new byte[2048];
while ((l = in.read(tmp)) != -1) {
fout.write(tmp);
}
fout.close();
} finally {
// 在用InputStream处理HttpEntity时,切记要关闭低层流。
in.close();
} httpget.releaseConnection();
} // Post方法,模拟表单提交参数登录到网站。
// 结合了上面两个方法:grabPageHTML/downloadFile,同时增加了Post的代码。
public void login2Lashou() throws Exception {
// 第一步:先下载验证码到本地
String url = "http://www.lashou.com/account/captcha";
String destfilename = "D:\\TDDOWNLOAD\\yz.png";
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
File file = new File(destfilename);
if (file.exists()) {
file.delete();
} HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
try {
FileOutputStream fout = new FileOutputStream(file);
int l = -1;
byte[] tmp = new byte[2048];
while ((l = in.read(tmp)) != -1) {
fout.write(tmp);
}
fout.close();
} finally {
in.close();
}
httpget.releaseConnection(); // 第二步:用Post方法带若干参数尝试登录,需要手工输入下载验证码中显示的字母、数字
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入下载下来的验证码中显示的数字...");
String yan = br.readLine(); HttpPost httppost = new HttpPost("http://www.lashou.com/account/login/");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("user_id", "testuser007"));
params.add(new BasicNameValuePair("pwd", "asdfg123"));
params.add(new BasicNameValuePair("yan", yan));
params.add(new BasicNameValuePair("save_user", "on"));
params.add(new BasicNameValuePair("save_pwd", "on"));
params.add(new BasicNameValuePair("sub", "登录"));
httppost.setEntity(new UrlEncodedFormEntity(params)); response = httpclient.execute(httppost);
entity = response.getEntity();
// 在这里可以用Jsoup之类的工具对返回结果进行分析,以判断登录是否成功
String postResult = EntityUtils.toString(entity, "GBK");
// 我们这里只是简单的打印出当前Cookie值以判断登录是否成功。
List<Cookie> cookies = ((AbstractHttpClient)httpclient).getCookieStore().getCookies();
for(Cookie cookie: cookies)
System.out.println(cookie);
httppost.releaseConnection(); // 第三步:打开会员页面以判断登录成功(未登录用户是打不开会员页面的)
String memberpage = "http://www.lashou.com/account/orders/";
httpget = new HttpGet(memberpage);
response = httpclient.execute(httpget); // 必须是同一个HttpClient!
entity = response.getEntity();
String html = EntityUtils.toString(entity, "GBK");
httpget.releaseConnection(); System.out.println(html);
} // 设置代理服务器
public void testProxy() throws Exception {
HttpHost proxy = new HttpHost("127.0.0.1", 8888); // 方式一
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); // 方式二
HttpParams params = new BasicHttpParams();
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
HttpClient httpclient1 = new DefaultHttpClient(params);
} // 几种常用HTTP头的设置
public void testBasicHeader() throws Exception {
HttpParams params = new BasicHttpParams();
Collection<BasicHeader> collection = new ArrayList<BasicHeader>();
collection.add(new BasicHeader("Accept", "text/html, application/xhtml+xml, */*"));
collection.add(new BasicHeader("Referer", "http://www.sina.com/"));
collection.add(new BasicHeader("Accept-Language", "zh-CN"));
collection.add(new BasicHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"));
collection.add(new BasicHeader("Accept-Encoding", "gzip, deflate"));
params.setParameter(ClientPNames.DEFAULT_HEADERS, collection); HttpClient httpclient = new DefaultHttpClient(params); // 下面内容略
} // 多线程编程下的线程池设置(这点在需要登录且用一个HttpClient对象抓取多个页面的情况下特别有用)
public void testConnectionManager() throws Exception {
// 连接池设置
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
cm.setMaxTotal(200); // 连接池里的最大连接数
cm.setDefaultMaxPerRoute(20); // 每个路由的默认最大连接数
HttpHost localhost = new HttpHost("locahost", 80); // 可以针对某特定网站指定最大连接数
cm.setMaxPerRoute(new HttpRoute(localhost), 30); // 其它设置
HttpParams params = new BasicHttpParams();
params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
HttpClient httpclient = new DefaultHttpClient(cm, params); // 下面内容略
} // 测试HTTP上下文对象(HttpContext)
public void testContext() throws Exception {
// 请求一个页面,然后解析各上下文对象
DefaultHttpClient httpclient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext();
HttpGet httpget = new HttpGet("http://www.baidu.com/"); HttpResponse response = httpclient.execute(httpget, localContext); // the actual connection to the target server.
HttpConnection conn = (HttpConnection) localContext.getAttribute(
ExecutionContext.HTTP_CONNECTION);
System.out.println("Socket timeout: " + conn.getSocketTimeout()); // the connection target
HttpHost target = (HttpHost) localContext.getAttribute(
ExecutionContext.HTTP_TARGET_HOST);
System.out.println("Final target: " + target); // the connection proxy, if used
HttpHost proxy = (HttpHost) localContext
.getAttribute(ExecutionContext.HTTP_PROXY_HOST);
if (proxy != null)
System.out.println("Proxy host/port: " + proxy.getHostName() + "/"
+ proxy.getPort()); // the actual HTTP request
HttpRequest request = (HttpRequest) localContext
.getAttribute(ExecutionContext.HTTP_REQUEST);
System.out.println("HTTP version: " + request.getProtocolVersion());
Header[] headers = request.getAllHeaders();
System.out.println("HTTP Headers: ");
for (Header header : headers) {
System.out.println("\t" + header.getName() + ": " + header.getValue());
}
System.out.println("HTTP URI: " + request.getRequestLine().getUri()); // the actual HTTP response
response = (HttpResponse) localContext
.getAttribute(ExecutionContext.HTTP_RESPONSE);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println("Content Encoding:" + entity.getContentEncoding());
System.out.println("Content Type:" + entity.getContentType());
} // the flag indicating whether the actual request has been fully transmitted to the connection target.
System.out.println("Sent flag: " + localContext.getAttribute(ExecutionContext.HTTP_REQ_SENT)); // 如果没有用到返回entity中的内容,那么要把它消费掉,以保证底层的资源得以释放。
entity = response.getEntity();
EntityUtils.consume(entity);
} public static void main(String[] args) throws Exception {
HttpClientSample1 ins = new HttpClientSample1(); // ins.grabPageHTML();
// ins.downloadFile();
ins.login2Lashou();
// ins.testContext();
}
}

Java:HttpClient篇,HttpClient4.2在Java中的几则应用:Get、Post参数、Session(会话)保持、Proxy(代理服务器)设置,多线程设置...的更多相关文章

  1. Java入门篇(三)——Java流程控制

    前两篇已经了解了Java语言基础,本篇开始Java的流程控制.流程控制对任何一门编程语言都是至关重要的,它提供了控制程序步骤的基本手段. 一.复合语句 Java语言的复合语句是以整个块区为单位的语句, ...

  2. Java入门篇(五)——Java的字符串/String类

    前面在举例时有出现过String的例子,当时肯定有一部分朋友不知道这个是做什么用的.其实String类是Java中一个比较特殊的类,字符串即String类,它不是Java的基本数据类型之一,但可以像基 ...

  3. Java入门篇(二)——Java语言基础(下)

    上篇说到Java中的变量与常量,接下来就是简单的计算了,首先需要了解一下Java中的运算符. 六.运算符 1. 赋值运算符 赋值运算符即"=",是一个二元运算符(即对两个操作数进行 ...

  4. Java进阶篇(五)——Java的I/O技术

    程序中,为了永久的保存创建的数据,需要将其保存在磁盘文件中,以便在其它程序中使用它们.Java的I/O技术可以将数据保存到文本文件.二进制文件甚至是ZIP压缩文件中,以达到永久性保存数据的要求. 本篇 ...

  5. Java提高篇(三八)-----Java集合细节(四):保持compareTo和equals同步

    在Java中我们常使用Comparable接口来实现排序,其中compareTo是实现该接口方法.我们知道compareTo返回0表示两个对象相等,返回正数表示大于,返回负数表示小于.同时我们也知道e ...

  6. Java提高篇(三六)-----Java集合细节(二):asList的缺陷

    在实际开发过程中我们经常使用asList讲数组转换为List,这个方法使用起来非常方便,但是asList方法存在几个缺陷: 一.避免使用基本数据类型数组转换为列表 使用8个基本类型数组转换为列表时会存 ...

  7. Java提高篇(三五)-----Java集合细节(一):请为集合指定初始容量

    集合是我们在Java编程中使用非常广泛的,它就像大海,海纳百川,像万能容器,盛装万物,而且这个大海,万能容器还可以无限变大(如果条件允许).当这个海.容器的量变得非常大的时候,它的初始容量就会显得很重 ...

  8. Java进阶篇(三)——Java集合类

    集合可以看作一个容器,集合中的对象可以很容易存放到集合中,也很容易将其从集合中取出来,还可以按一定的顺序摆放.Java中提供了不同的集合类,这些类具有不同的存储对象的方式,并提供了相应的方法方便用户对 ...

  9. Java进阶篇(四)——Java异常处理

    程序中总是存在着各种问题,为了使在程序执行过程中能正常运行,使用Java提供的异常处理机制捕获可能发生的异常,对异常进行处理并使程序能正常运行.这就是Java的异常处理. 一.可捕获的异常 Java中 ...

  10. 基础篇:深入解析JAVA反射机制

    目录 反射的概念 获取Class的三种方法 JAVA反射API 反射机制应用的场景 反射和JDK动态代理 欢迎指正文中错误 关注公众号,一起交流 参考文章 反射的概念 java的放射机制:在程序运行时 ...

随机推荐

  1. DigCSDN介绍首页

    recrefer=SE_D_DigCSDN">360手机助手下载地址 兴许平台会陆续登陆上线的,大家敬请期待 最后由于屏幕适配和分享链接的问题,导致最后的公布时间延误了好几天--- 今 ...

  2. JSP基本的语法、3个编译指令、7个动作指令、9个内置对象

    一.jsp概述 JSP是java server page的缩写,其本质是一个简化的servlet,是一种动态网页技术标准.jsp页面是在HTML页面中嵌入java程序段.使用jsp开发的应用程序能够跨 ...

  3. 嵌套循环连接(nested loops join)原理

    嵌套循环连接(nested loops join) 访问次数:驱动表返回几条,被驱动表访问多少次. 驱动表是否有顺序:有. 是否要排序:否.    应用场景:  1.关联中有一个表比较小: 2.被关联 ...

  4. 解决pl/sql 查询数据中文显示成?

    解决方法: 1.打开 PLSQL Developer 安装目录下,看到有PLSQLDev.exe的目录, 在PLSQL Developer文件夹内新建“PLSql_run.bat”文件,在该文件中输入 ...

  5. Java从零开始学十五(继承)

    一.继承作用 继承使用复用以前的代码非常容易,能够大大的缩短开发周期,降低开发成本,同时增加程序的易维护性 继承使重一个类A能够直接使用另外一个类B的属性和方法的一种途径 类A可以有自己的属性和方法 ...

  6. 算法笔记_177:历届试题 城市建设(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 问题描述 栋栋居住在一个繁华的C市中,然而,这个城市的道路大都年久失修.市长准备重新修一些路以方便市民,于是找到了栋栋,希望栋栋能帮助他. C市中有 ...

  7. JAR,WAR,EAR区别

    JAR WAR EAR 英文 Java Archive file Web Archive file Enterprise Archive file 包含内容 class.properties文件,是文 ...

  8. 全球免费知名DNS服务器

    全球免费知名DNS服务器 jalone 2013-06-18 14:25:46 最近老是发表DNS相关文章,今天继续说DNS,国内75%以上的家用宽带路由器存在严重的安全隐患:用户浏览网页的时候其DN ...

  9. 华硕M2A-VM+AMD4000超频方法

    华硕M2A-VM+AMD4000超频方法2009-07-07 09:42 1.4000+默认外频为200,倍频已经锁定为10.5,实际运行频率为2100HZ.超频是通过提高外频来实现的,只要适当提高外 ...

  10. Linux下umask的缺省默认权限

    Linux有缺省默认文件.文件夹权限umask.默认 777 -xxx(文件夹)  666 - xxx(文件) 11.查看当前用户umask R(4)--W(2)--X(1) [root@mvpban ...