Java模拟HTTP的Get和Post请求
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public final class HttpTookit {
private static Log log = LogFactory.getLog(HttpTookit.class);
public static String doGet(String url, String queryString) {
String response = null;
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod(url);
try {
if (StringUtils.isNotBlank(queryString))
method.setQueryString(URIUtil.encodeQuery(queryString));
相关文档:
l组件从功能上分可分为:
1) 顶层容器:JFrame,JApplet,JDialog,JWindow
2) 中间容器:JPanel,JScrollPane,JSplitPane,JToolBar
3) 特殊容器:在GUI上起特殊作用的中间层,如JInternalFrame,JLayeredPane,JRootPane.
1.JFrame的用法
1) 用getContentPane( )方法获得JFrame的 ......
package com.kiloway.trace.utils;
import java.lang.reflect.Field;
/**
* @author Zhang Qi
* @Create Time 2010/01/09
* */
public class ObjectToXML {
public String toString(Object object) throws Exception {
StringBuilder sb = new StringBuilder();
//得到类的名称
String classname = obj ......
xml中键名为 英文,键值为中文,读取解析,取值实现翻译
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList; ......
public class javaTest {
public static void test(String ...strings){
for(String str: strings){
System.out.print(str + " ");
}
System.out.println();
}
public static void main(String[] args){
test("a", "b", "c", "ddd");
test( ......
通过 DAOFactory 的泛型写法来演示Java泛型的特殊用法
小型项目中常常都没有用三方持久化框架,而大都是用公司或自行依据DAO模式封装的一些组件来完成数据库持久化动作,并且,通常为了更具可扩展性,常常使用抽象工厂模式来解耦合。
一、先看代码
1、简单工厂代码
/************************************************* ......