Java NIO
Why NIO ?
http://onjava.com/pub/a/onjava/2002/09/04/nio.html?page=1
Java developers might ask: why introducing a new technology to handle sockets? What's wrong with the Java 1.3.x sockets? Suppose you would like to implement a server accepting diverse client connections. Suppose, as well, that you would like the server to be able to process multiple requests simultaneously. Using Java 1.3.x, you have two choices to develop such a server:
Implement a multithread server that manually handles a thread for each connection.
Using an external third-party module.
Both solutions work, but adopting the first one -- the whole thread-management solution, with related concurrency and conflict troubles -- has to be developed by programmer. The second solution may cost money, and it makes the application dependent on a non-JDK external module. By means of the nonblocking socket, you can implement a nonblocking server without directly managing threads or resorting to external modules.
In internal benchmarks, the router was able to handle up to 10,000 clients with no significant drop in throughput. For comparison, we implemented a version based on the thread-per-client model, which was only able to reach 3,000 clients, with a significant drop in throughput as the number of clients increased. (Thread Pool not alleviate it)
http://java.sun.com/j2se/1.4.2/docs/guide/nio/example/index.html
http://rox-xmlrpc.sourceforge.net/niotut/
Q: use loop to read or read assembling ?
/**
* several reads
*/
ByteBuffer buffer = ByteBuffer.allocate(10 * 1024);
...
int readBytes = sc.read(inBuffer);
buffer.put(inBuffer);
int target = 1024;
if(buffer.position() == 1024)
//get all the data, handle it
else
//hold buffer for next read
/**
* read in loop
*/
int target = 1024;
int totalRead = 0;
while(totalRead != 1024)
{
int readBytes = sc.read(intBuffer);
if(readBytes == -1)
break;
totalRead += readBytes;
}
//get all the data, handle it
相关文档:
Java 6 RowSet 使用完全剖析(1)
关键字: rowset
javax.sql.rowset 自 JDK 1.4 引入,从 JDK 5.0 开始提供了参考实现。它主要包括 CachedRowSet,WebRowSet,FilteredRowSet,JoinRowSet 和 JdbcRowSet。 除了 JdbcRowSet 依然保持着与数据源的连接之外,其余四个都是 Disconnected RowSet。
相比较 java.sql.ResultSet ......
光荣的在期末再一次患上了“化脓性扁桃体炎”。带着39度的体温考试的确不是个舒服的事,那几天这把我给急得啊,总不能在这个时候晚节不保吧?真不知是为什么,这个病在这半个学期里折磨了我好几次,弄的我都对自己没什么信心了,希望这回在家里能够好好调整修养一番,开始新的旅程。
毕设的题目也出来了,只不过 ......
java的基本数据类型以及长度如下:
1.整数型
字节型byte:占1个字节 范围为 -28-1至28-1-1
短整型short:占2个字节 范围为 -22*8-1 至 22*8-1-1
& ......
java中基本数据类型按精度低高的排列顺序是
byte<short<int<long<float<double
1.当把级别低的变量的值赋给级别高的变量时,系统会自动完成数据类型的转换 ......
每天基础(1),串匹配之Brute-Force算法,最简单的遍历算法。另外有KMP算法,是对此算法的改进,避免每次比较都回回退。
package ibees.sample;
/**
* 字符串匹配模式算法Brute-Force算法,此算法每次比较都会回退
* @author hhzxj2008
* */
public class StringMatch {
/**
* 相当于java.lang.String的i ......