Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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±àд¶àÏß³Ìftp¶ÏµãÏÂÔØÎļþ³ÌÐò


×÷Õß
:
ÀîÖ¾ÌÎ
ÓÊÏ䵨ַ
:lizhitao67116961@163.com
ÉîÛÚÓÅÍø¿Æ¼¼ÓÐÏÞ¹«Ë¾
 
ǰ¼¸Ìì¿´µ½ÓÐÄ³Î»ÍøÓÑдÁËÓÃhttp½øÐжϵãÏÂÔØÎļþ£¬µ«ÊÇÍøÉÏûÓп´µ½ftp¶ÏµãÏÂÔØµÄÎÄÕ»ò´úÂ룬ÏÖÔÚ±¾ÈËдÁËһϡ£¾­¹ý²âÊÔûÓÐÎÊÌâ¡£Çë´ó¼Ò¶à¶àÖ¸½Ì¡£ÈçÓÐÊ詵ĵط½Çë¸÷λ¼¼ÊõÓÑÈËÖ¸³ö¡£±¾È˲»Ê¤¸Ð¼¤¡£
 
package
test.d ......

ÓÃjava±àд¶àÏß³Ìftp¶ÏµãÏÂÔØÎļþ³ÌÐò

×÷Õß : ÀîÖ¾ÌÎ
ÓÊÏ䵨ַ :lizhitao67116961@163.com
ÉîÛÚÓÅÍø¿Æ¼¼ÓÐÏÞ¹«Ë¾
 
ǰ¼¸Ìì¿´µ½ÓÐÄ³Î»ÍøÓÑдÁËÓÃhttp½øÐжϵãÏÂÔØÎļþ£¬µ«ÊÇÍøÉÏûÓп´µ½ftp¶ÏµãÏÂÔØµÄÎÄÕ»ò´úÂ룬ÏÖÔÚ±¾ÈËдÁËһϡ£¾­¹ý²âÊÔûÓÐÎÊÌâ¡£Çë´ó¼Ò¶à¶àÖ¸½Ì¡£ÈçÓÐÊ詵ĵط½Çë¸÷λ¼¼ÊõÓÑÈËÖ¸³ö¡£±¾È˲»Ê¤¸Ð¼¤¡£
 
 
package t ......

Java 6 RowSet ʹÓÃÍêÈ«ÆÊÎö(1)

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 ......

Java 6 RowSet ʹÓÃÍêÈ«ÆÊÎö(3)

Java 6 RowSet ʹÓÃÍêÈ«ÆÊÎö(3)
¹Ø¼ü×Ö: rowset
Çåµ¥ 24. Çåµ¥ 23 ÖеĴúÂëÖ´Ðнá¹û
1 Tom Tom is VIP. 2 Jim null
ÏÂÃæÒ»½ÚÀïÎÒÃǽ«»á¿´µ½ JdbcRowSet ÈçºÎ×÷Ϊһ¸ö RowSet ºÍÆäËûµÄ RowSet Ò»ÆðʹÓá£
ʹÓà JoinRowSet
Ö§³ÖµÄÁªºÏ·½Ê½
JoinRowSet ½Ó¿ÚÖжÔÎåÖÖ²»Í¬µÄÁªºÏ·½Ê½¶¼¶¨ÒåÁ˶ÔÓ¦µÄ³£ÊýºÍÅжϸÃʵÏÖÊÇ·ñÖ ......

JavaÓÃAWTʵÏÖµÄ״̬À¸

      AWTÖÐûÓÐÌṩ״̬À¸¹¤¾ß£¬¿ÉÒÔÔÚFrameÖÐÌí¼ÓÒ»¸öPanelʵÏÖÀàËÆµÄ¹¦ÄÜ¡£»ù±¾¹¦ÄÜÓд´½¨×´Ì¬À¸£¬Ìí¼ÓָʾÆ÷£¬ÒƳýָʾÆ÷£¬¸Ä±äָʾÆ÷ÄÚÈÝ£¬»ñµÃָʾÆ÷ÄÚÈÝ£¬Ìí¼ÓָʾÆ÷Êó±êÏûÏ¢ÏìÓ¦£¬Ìí¼ÓָʾÆ÷ÓÒ¼üµ¯³ö²Ëµ¥£¬»ñµÃ¶ÔÒ»¸öָʾÆ÷µÄÒýÓõȡ£
import java.awt.Color;
import java.awt.Componen ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ