socket, nio socket,及xml传递object 方法
1:如何通过socket代理来访问服务端:
String proxyHost =
"192.168.204.212"
;
String proxyPort =
"1080"
;
//通知Java要通过代理进行连接。
正在装载数据……
System.getProperties().put(
"socksProxySet"
,
"true"
);
//指定代理所在的机器
System.getProperties().put(
"socksProxyHost"
,proxyHost);
//指定代理监听的端口。
System.getProperties().put(
"socksProxyPort"
,proxyPort);
String host =
"134.01.69.80"
;
int
port =
12086
;
System.out.println(
"connetioning:"
+ host +
":"
+ port);
server =
new
Socket(host, port);
二:老socket传递Object对象:
要传递的对象:
public
class
Employee
implements
Serializable {
private
int
employeeNumber;
private
String employeeName;
Employee(
int
num, String name) {
employeeNumber = num;
employeeName= name;
}
public
int
getEmployeeNumber() {
相关文档:
使用dom4j解析XML时,要快速获取某个节点的数据,使用XPath是个不错的方法,dom4j的快速手册里也建议使用这种方式,标题都写的这么阔气:Powerful Navigation with XPath,呵呵。
方法是使用Document的selectNodes(String XPath)方法,代码写法:
List l = doc.selectNodes("//COLS/COL1");
执行时却抛出以下异常:
Exc ......
xml
<mime>
<content>
<type>text/plain</type>
<big>357</big>
<text>D:\\cybercourttext2009101410241364.txt</text>
</content>
<content>
<type>text/plain</type>
<big>357</big>
<text>D:\\cybercourttext2009 ......
XPath 语法
2007-06-05 17:24
XPath 语法
作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-29 浏览:674 :: ::
XPath Nodes(节点) XPath Axes
XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.
XPath 通过路径表达式从XM ......
public static IList<News> GetAllNews()
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load("你读取的地址:例如 ......