NIO Socket编程实例
1.阻塞模式实例
NIOUtil类,用来通过SOcket获取BufferedReader和PrintWriter。
package IO; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket; public class NIOUtil {
public static PrintWriter getPrintWriter(Socket socket) throws IOException {
OutputStream outputStream = socket.getOutputStream();
return new PrintWriter(outputStream, true);
} public static BufferedReader getBufferedReader(Socket socket)
throws IOException {
InputStream inputStream = socket.getInputStream();
return new BufferedReader(new InputStreamReader(inputStream));
}
}
使用ServerSocketChannel创建阻塞服务器端程序:
package IO; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; public class BlockingNIOServer {
private int port = 8000;
private ServerSocketChannel serverSocketChannel = null;
private ExecutorService executorService = null;
private static int DEFAULT_POOI_SIZE = 4; public BlockingNIOServer() throws IOException {
super();
this.executorService = Executors.newFixedThreadPool(DEFAULT_POOI_SIZE
* Runtime.getRuntime().availableProcessors());
this.serverSocketChannel = ServerSocketChannel.open();
serverSocketChannel.socket().setReuseAddress(true);
serverSocketChannel.socket().bind(new InetSocketAddress(port));
this.executorService = executorService;
} public void service() {
while (true) {
SocketChannel channel = null;
try {
channel = serverSocketChannel.accept();
executorService.execute(new Handler(channel));
} catch (Exception e) {
e.printStackTrace();
}
}
} public static void main(String[] args) throws Exception {
new BlockingNIOServer().service();
} private class Handler implements Runnable {
private SocketChannel channel;
public Handler(SocketChannel channel) {
super();
this.channel = channel;
} @Override
public void run() {
handler(channel);
} public void handler(SocketChannel channel) {
Socket socket = null;
try {
socket = channel.socket();
System.out.println("接收到来自:" + socket.getInetAddress() + " 端口:"
+ socket.getPort() + "的请求");
BufferedReader bufferedReader = NIOUtil
.getBufferedReader(socket);
PrintWriter printWriter = NIOUtil.getPrintWriter(socket);
String msg = null; while ((msg = bufferedReader.readLine()) != null) {
System.out.println(msg);
printWriter.println(Echo(msg));
if ("bye".equalsIgnoreCase(msg))
break;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (channel != null) {
try {
channel.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} } private String Echo(String msg) {
return "ECHO:" + msg;
}
}
}
使用SocketChannel创建阻塞Socket客户端:
package IO; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; public class BlockingNIOServer {
private int port = 8000;
private ServerSocketChannel serverSocketChannel = null;
private ExecutorService executorService = null;
private static int DEFAULT_POOI_SIZE = 4; public BlockingNIOServer() throws IOException {
super();
this.executorService = Executors.newFixedThreadPool(DEFAULT_POOI_SIZE
* Runtime.getRuntime().availableProcessors());
this.serverSocketChannel = ServerSocketChannel.open();
serverSocketChannel.socket().setReuseAddress(true);
serverSocketChannel.socket().bind(new InetSocketAddress(port));
this.executorService = executorService;
} public void service() {
while (true) {
SocketChannel channel = null;
try {
channel = serverSocketChannel.accept();
executorService.execute(new Handler(channel));
} catch (Exception e) {
e.printStackTrace();
}
}
} public static void main(String[] args) throws Exception {
new BlockingNIOServer().service();
} private class Handler implements Runnable {
private SocketChannel channel;
public Handler(SocketChannel channel) {
super();
this.channel = channel;
} @Override
public void run() {
handler(channel);
} public void handler(SocketChannel channel) {
Socket socket = null;
try {
socket = channel.socket();
System.out.println("接收到来自:" + socket.getInetAddress() + " 端口:"
+ socket.getPort() + "的请求");
BufferedReader bufferedReader = NIOUtil
.getBufferedReader(socket);
PrintWriter printWriter = NIOUtil.getPrintWriter(socket);
String msg = null; while ((msg = bufferedReader.readLine()) != null) {
System.out.println(msg);
printWriter.println(Echo(msg));
if ("bye".equalsIgnoreCase(msg))
break;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (channel != null) {
try {
channel.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} } private String Echo(String msg) {
return "ECHO:" + msg;
}
}
}
2.非阻塞模式实例
Charset类,主要用于decode()和encode()
package IO; import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset; public class CharSetUtil {
public static String decode(ByteBuffer buffer, String charsetName) {
Charset charset = Charset.forName(charsetName);
CharBuffer msg = charset.decode(buffer);
return msg.toString();
} public static ByteBuffer encode(String msg, String charsetName) {
Charset charset = Charset.forName(charsetName);
ByteBuffer byteBuffer = charset.encode(msg);
return byteBuffer;
}
}
非阻塞的服务器端
package IO; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; public class NoBlockingServer {
private int port = 8000;
private ServerSocketChannel serverSocketChannel = null;
private Selector selector = null; public NoBlockingServer() throws IOException {
super();
selector = Selector.open();
this.serverSocketChannel = ServerSocketChannel.open();
serverSocketChannel.socket().setReuseAddress(true);
serverSocketChannel.configureBlocking(false);//设置为非阻塞
serverSocketChannel.socket().bind(new InetSocketAddress(port));
System.out.println("服务器启动成功");
} public void service() throws IOException {
//给serverSocketChannel注册OP_ACCEPT事件
serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
//注意selector.select()将会阻塞
while (selector.select() > 0) {
Set<SelectionKey> selectionKeys = selector.selectedKeys();
Iterator iterator = selectionKeys.iterator();
while (iterator.hasNext()) {
SelectionKey selectionKey = null;
try {
selectionKey = (SelectionKey) iterator.next();
iterator.remove(); if (selectionKey.isAcceptable()) {
dealWithAcceptable(selectionKey);
}
if (selectionKey.isReadable()) {
dealWithReadable(selectionKey);
}
if (selectionKey.isWritable()) {
dealWithWritable(selectionKey);
}
} catch (Exception e) {
if (selectionKey != null) {
selectionKey.cancel();
selectionKey.channel().close();
}
}
}
}
} private void dealWithAcceptable(SelectionKey selectionKey)
throws IOException {
ServerSocketChannel serverSocketChannel = (ServerSocketChannel) selectionKey
.channel();
SocketChannel socketChannel = serverSocketChannel.accept();
System.out.println("接收到来自:" + socketChannel.socket().getInetAddress()
+ " 端口" + socketChannel.socket().getPort() + "的请求");
socketChannel.configureBlocking(false);
ByteBuffer buffer = ByteBuffer.allocate(1024);
socketChannel.register(selectionKey.selector(), SelectionKey.OP_READ
| SelectionKey.OP_WRITE, buffer);
} private void dealWithReadable(SelectionKey selectionKey) throws IOException{
ByteBuffer buffer=(ByteBuffer) selectionKey.attachment();
SocketChannel channel=(SocketChannel) selectionKey.channel();
ByteBuffer readBuffer=ByteBuffer.allocate(32);
channel.read(readBuffer);
readBuffer.flip(); buffer.limit(buffer.capacity());
buffer.put(readBuffer);
} private void dealWithWritable(SelectionKey selectionKey) throws IOException{
ByteBuffer buffer=(ByteBuffer) selectionKey.attachment();
SocketChannel channel=(SocketChannel) selectionKey.channel();
buffer.flip(); String msg=CharSetUtil.decode(buffer, "UTF-8"); if(msg.indexOf("\r\n")==-1){
return;
} String outPutData=msg.substring(0, msg.indexOf("\n")+1);
System.out.println("接收来自客户端的数据:"+outPutData); ByteBuffer outbyteBuffer=CharSetUtil.encode("echo:"+outPutData, "UTF-8");
while (outbyteBuffer.hasRemaining()) {
channel.write(outbyteBuffer);
} ByteBuffer tmp=CharSetUtil.encode(outPutData, "UTF-8");
buffer.position(tmp.limit());
buffer.compact();
if("bye\r\n".equalsIgnoreCase(outPutData)){
selectionKey.cancel();
channel.close();
System.out.println("关闭与客户端的连接");
}
} public static void main(String[] args) throws Exception {
new NoBlockingServer().service();
}
}
非阻塞的客户端
package IO; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Set; public class NoBlockingClient {
private SocketChannel channel = null;
private ByteBuffer send = ByteBuffer.allocate(1024);
private ByteBuffer rece = ByteBuffer.allocate(1024);
private Selector selector; public NoBlockingClient() throws IOException {
super();
channel = SocketChannel.open();
channel.socket().connect(new InetSocketAddress("localhost", 8000));
channel.configureBlocking(false); System.out.println("与服务器建立连接成功");
selector = Selector.open();
} public void talk() throws IOException {
channel.register(selector, SelectionKey.OP_READ|SelectionKey.OP_WRITE);
while (selector.select() > 0) {
Set<SelectionKey> selectionKeys = selector.selectedKeys();
Iterator iterator = selectionKeys.iterator();
while (iterator.hasNext()) {
SelectionKey selectionKey = null;
try {
selectionKey = (SelectionKey) iterator.next();
iterator.remove(); if (selectionKey.isReadable()) {
dealWithReadable(selectionKey);
}
if (selectionKey.isWritable()) {
dealWithWritable(selectionKey);
}
} catch (Exception e) {
if (selectionKey != null) {
selectionKey.cancel();
try {
selectionKey.channel().close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
}
} private void receFromUser() throws IOException{
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
String msg=null;
while ((msg=bufferedReader.readLine())!=null) {
synchronized (send) {
send.put(CharSetUtil.encode(msg+"\r\n", "UTF-8"));
}
if ("bye".equalsIgnoreCase(msg)) {
break;
}
}
} private void dealWithWritable(SelectionKey selectionKey) throws IOException{
SocketChannel channel=(SocketChannel) selectionKey.channel();
synchronized (send) {
send.flip();
channel.write(send);
send.compact();
}
} private void dealWithReadable(SelectionKey selectionKey) throws IOException{
SocketChannel channel=(SocketChannel) selectionKey.channel();
channel.read(rece);
rece.flip();
String msg=CharSetUtil.decode(rece, "UTF-8"); if(msg.indexOf("\r\n")==-1){
return;
} String outPutData=msg.substring(0, msg.indexOf("\n")+1);
System.out.println(outPutData); if("echo:bye\r\n".equalsIgnoreCase(outPutData)){
selectionKey.cancel();
channel.close();
selector.close();
System.out.println("关闭与客户端的连接");
} ByteBuffer tmp=CharSetUtil.encode(outPutData, "UTF-8");
rece.position(tmp.limit());
rece.compact();
} public static void main(String[] args) throws IOException {
System.out.println(System.getProperty("file.encoding"));
final NoBlockingClient noBlockingClient=new NoBlockingClient();
Thread thread=new Thread(){
public void run() {
try {
noBlockingClient.receFromUser();
} catch (IOException e) {
e.printStackTrace();
}
};
}; thread.start();
noBlockingClient.talk();
}
}
3.阻塞和非阻塞编程实例
服务器端使用阻塞和非阻塞模式,f负责接收客户端连接的线程按照阻塞模式工作,负责接收和发送数据的线程按照非阻塞模式工作。
package IO; import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Set; public class NOBlockingAndBolckingServer {
private int port = 8000;
private ServerSocketChannel serverSocketChannel = null;
private Selector selector = null;
private Object gate = new Object(); public NOBlockingAndBolckingServer() throws IOException {
super();
selector = Selector.open();
this.serverSocketChannel = ServerSocketChannel.open();
serverSocketChannel.socket().bind(new InetSocketAddress(port));
System.out.println("服务器启动成功");
} public void accept() {
for (;;) {
try {
SocketChannel socketChannel = serverSocketChannel.accept();
System.out.println("接收到来自:"
+ socketChannel.socket().getInetAddress() + " 端口"
+ socketChannel.socket().getPort() + "的请求");
socketChannel.configureBlocking(false); synchronized (gate) {
selector.wakeup();
socketChannel.register(selector, SelectionKey.OP_READ
| SelectionKey.OP_WRITE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
} public void service() throws IOException {
// 给serverSocketChannel注册OP_ACCEPT事件
for (;;) {
synchronized (gate) {
int n = selector.select();
if (n == 0)
continue;
Set<SelectionKey> selectionKeys = selector.selectedKeys();
Iterator iterator = selectionKeys.iterator();
while (iterator.hasNext()) {
SelectionKey selectionKey = null;
try {
selectionKey = (SelectionKey) iterator.next();
iterator.remove(); if (selectionKey.isReadable()) {
dealWithReadable(selectionKey);
}
if (selectionKey.isWritable()) {
dealWithWritable(selectionKey);
}
} catch (Exception e) {
if (selectionKey != null) {
selectionKey.cancel();
selectionKey.channel().close();
}
}
}
}
}
} private void dealWithReadable(SelectionKey selectionKey) throws IOException {
ByteBuffer buffer = (ByteBuffer) selectionKey.attachment();
SocketChannel channel = (SocketChannel) selectionKey.channel();
ByteBuffer readBuffer = ByteBuffer.allocate(32);
channel.read(readBuffer);
readBuffer.flip(); buffer.limit(buffer.capacity());
buffer.put(readBuffer);
} private void dealWithWritable(SelectionKey selectionKey) throws IOException {
ByteBuffer buffer = (ByteBuffer) selectionKey.attachment();
SocketChannel channel = (SocketChannel) selectionKey.channel();
buffer.flip(); String msg = CharSetUtil.decode(buffer, "UTF-8"); if (msg.indexOf("\r\n") == -1) {
return;
} String outPutData = msg.substring(0, msg.indexOf("\n") + 1);
System.out.println("接收来自客户端的数据:" + outPutData); ByteBuffer outbyteBuffer = CharSetUtil.encode("echo:" + outPutData,
"UTF-8");
while (outbyteBuffer.hasRemaining()) {
channel.write(outbyteBuffer);
} ByteBuffer tmp = CharSetUtil.encode(outPutData, "UTF-8");
buffer.position(tmp.limit());
buffer.compact();
if ("bye\r\n".equalsIgnoreCase(outPutData)) {
selectionKey.cancel();
channel.close();
System.out.println("关闭与客户端的连接");
}
} public static void main(String[] args) throws Exception {
final NOBlockingAndBolckingServer server=new NOBlockingAndBolckingServer();
Thread thread=new Thread(){
public void run() {
server.accept();
};
};
thread.start();
server.service();
}
}
客户端和服务器端创建多个连接。
package IO; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.LinkedList; class Target { // 表示一项任务
InetSocketAddress address;
SocketChannel channel;
Exception failure;
long connectStart; // 开始连接时的时间
long connectFinish = 0; // 连接成功时的时间
boolean shown = false; // 该任务是否已经打印 Target(String host) {
try {
address = new InetSocketAddress(InetAddress.getByName(host), 80);
} catch (IOException x) {
failure = x;
}
} void show() { // 打印任务执行的结果
String result;
if (connectFinish != 0)
result = Long.toString(connectFinish - connectStart) + "ms";
else if (failure != null)
result = failure.toString();
else
result = "Timed out";
System.out.println(address + " : " + result);
shown = true;
}
} public class PingClient {
private Selector selector;
// 存放用户新提交的任务
private LinkedList targets = new LinkedList();
// 存放已经完成的需要打印的任务
private LinkedList finishedTargets = new LinkedList(); public PingClient() throws IOException {
selector = Selector.open();
Connector connector = new Connector();
Printer printer = new Printer();
connector.start();
printer.start();
receiveTarget();
} public static void main(String args[]) throws IOException {
new PingClient();
} public void addTarget(Target target) {
// 向targets队列中加入一个任务
SocketChannel socketChannel = null;
try {
socketChannel = SocketChannel.open();
socketChannel.configureBlocking(false);
socketChannel.connect(target.address); target.channel = socketChannel;
target.connectStart = System.currentTimeMillis(); synchronized (targets) {
targets.add(target);
}
selector.wakeup();
} catch (Exception x) {
if (socketChannel != null) {
try {
socketChannel.close();
} catch (IOException xx) {
}
}
target.failure = x;
addFinishedTarget(target);
}
} public void addFinishedTarget(Target target) {
// 向finishedTargets队列中加入一个任务
synchronized (finishedTargets) {
finishedTargets.notify();
finishedTargets.add(target);
}
} public void printFinishedTargets() {
// 打印finisedTargets队列中的任务
try {
for (;;) {
Target target = null;
synchronized (finishedTargets) {
while (finishedTargets.size() == 0)
finishedTargets.wait();
target = (Target) finishedTargets.removeFirst();
}
target.show();
}
} catch (InterruptedException x) {
return;
}
} public void registerTargets() {
// 取出targets队列中的任务,向Selector注册连接就绪事件
synchronized (targets) {
while (targets.size() > 0) {
Target target = (Target) targets.removeFirst(); try {
target.channel.register(selector, SelectionKey.OP_CONNECT,
target);
} catch (IOException x) {
try {
target.channel.close();
} catch (IOException e) {
e.printStackTrace();
}
target.failure = x;
addFinishedTarget(target);
}
}
}
} public void processSelectedKeys() throws IOException {
// 处理连接就绪事件
for (Iterator it = selector.selectedKeys().iterator(); it.hasNext();) {
SelectionKey selectionKey = (SelectionKey) it.next();
it.remove(); Target target = (Target) selectionKey.attachment();
SocketChannel socketChannel = (SocketChannel) selectionKey
.channel(); try {
if (socketChannel.finishConnect()) {
selectionKey.cancel();
target.connectFinish = System.currentTimeMillis();
socketChannel.close();
addFinishedTarget(target);
}
} catch (IOException x) {
socketChannel.close();
target.failure = x;
addFinishedTarget(target);
}
}
} //接收用户输入的地址,向targets队列中加入任务
public void receiveTarget() {
try {
BufferedReader localReader = new BufferedReader(
new InputStreamReader(System.in));
String msg = null;
while ((msg = localReader.readLine()) != null) {
if (!msg.equals("bye")) {
Target target = new Target(msg);
addTarget(target);
} else {
shutdown = true;
selector.wakeup();
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
} boolean shutdown = false; public class Printer extends Thread {
public Printer() {
setDaemon(true);
} public void run() {
printFinishedTargets();
}
} public class Connector extends Thread {
public void run() {
while (!shutdown) {
try {
registerTargets();
if (selector.select() > 0) {
processSelectedKeys();
}
} catch (Exception e) {
e.printStackTrace();
}
}
try {
selector.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
NIO Socket编程实例的更多相关文章
- Java NIO Socket编程实例
		各I/O模型优缺点 BIO通信模型 BIO主要的问题在于每当有一个新的客户端请求接入时,服务端必须创建一个新的线程处理新接入的客户端链路,一个线程只能处理一个客户端连接 线程池I/O编程 假如所有可用 ... 
- linux下socket编程实例
		linux下socket编程实例一.基本socket函数Linux系统是通过提供套接字(socket)来进行网络编程的.网络的socket数据传输是一种特殊的I/O,socket也是一种文件描述符.s ... 
- 【转】netlink socket编程实例
		[转]netlink socket编程实例 转自:http://blog.chinaunix.net/uid-14753126-id-2983915.html 关于Netlink IPC方式的介绍,请 ... 
- TCP/UDP套接字 java socket编程实例
		网络协议七层结构: 什么是Socket? socket(套接字)是两个程序之间通过双向信道进行数据交换的端,可以理解为接口.使用socket编程也称为网络编程,socket只是接口并不是网络通信协议. ... 
- [转] - linux下socket编程实例
		一.基本socket函数Linux系统是通过提供套接字(socket)来进行网络编程的.网络的socket数据传输是一种特殊的I/O,socket也是一种文件描述符.socket也有一个类似于打开文件 ... 
- C++/C socket编程实例
		目录 基于TCP的socket编程 服务器代码 客户端代码 运行结果 基于UDP的socket编程 服务器代码 客户端代码 运行结果 基于TCP的socket编程 服务器代码 服务器端代码如下 //T ... 
- java socket编程实例代码
		1.所谓socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄.应用程序通常通过"套接字"向网络发出请求或者应答网络请求. 两性话题 两性 ... 
- 网络编程之socket编程实例
		简单实例1 server.c #include <stdio.h> #include <string.h> #include <stdlib.h> #include ... 
- Linux下的C++ socket编程实例
		阅读目录 基本的局域网聊天 客户端服务端双向异步聊天源码 局域网内服务端和有限个客户端聊天源码 完美异步聊天服务端和客户端源码 C++定时器 select异步代码 pthead多线程 服务端: 服务器 ... 
随机推荐
- 区分 点操作符+属性名 和 getAttribute()
			在用DOM操作控制HTML时,很多初学者会把 点操作符+属性名 与getAttribute("属性名") 混淆,误以为这两种方法是等价的. 实际上, 通过getAttribute( ... 
- AE + GDAL实现影像按标准图幅分割(下)
			在上篇实现了遥感影像的切割,本篇讲切割前的准备.主要分为以下几步: (1)将影像的投影坐标转换为地理坐标,以便于之后的图幅划分.AE坐标转换函数如下 private bool Proj2Geo(ISp ... 
- .NET中数据访问方式(一):LINQ
			语言集成查询(Language-Integrated Query),简称LINQ,.NET中的LINQ体系如下图所示: 在编程语言层次,LINQ对于不同的数据源提供了相同的查询语法,方便了程序员操 ... 
- es6 module + webpack
			其实在之前本人就看了 es6 里面的一部分内容,当然是阮一峰大神的 ECMAScript 6 入门. 最近闲来无事又来看下,其中 Module 的语法 这章时候,用里面代码跑的时候,理所当然的报错 S ... 
- 解决Tomcat: Can't load IA 32-bit .dll on a AMD 64-bit platform 问题
			错误如下: java.lang.UnsatisfiedLinkError: E:\Program Files\MyEclipse 10\apache-tomcat-7.0.23\bin\tcnativ ... 
- 一道CVTE前端二面笔试题
			题目:给你一个数组,输出数组中出现次数第n多的数字; 比如:[1,1,1,2,2,2,3,3,4,4,5,5,6,6,7]; 1---3次 2---3次 3---2次 4---2次 5---2次 6- ... 
- Google Chrome 默认非安全端口列表
			1, // tcpmux7, // echo 9, // discard 11, // systat 13, // daytime 15, // netstat 17, // qotd 19, // ... 
- Go - 第一个 go 程序 -- helloworld
			创建程序目录 接着上一节的内容,在我们的workspace (D:\Gopher) 里面创建子目录 hello,他的绝对路径为:D:\Gopher\src\github.com\tuo\hello 创 ... 
- 记一次使用修改字节码的方法解决java.lang.NoSuchMethodError
			接兔兔国际sdk ane 充值界面选择兔币充值就会闪退, 观察logcat 04-19 10:10:54.224: E/AndroidRuntime(20315): FATAL EXCEPTION: ... 
- Jmeter如何将上一个请求的结果作为下一个请求的参数——使用正则表达式提取器
			首先在线程组下添加两个HTTP请求, 添加好两个HTTP请求后,在每个HTTP请求下添加一个查看结果数 在第一个HTTP请求下添加正则表达式提取器 在第一个HTTP请求添加好IP地址,路径,端口号,协 ... 
