易截截图软件、单文件、免安装、纯绿色、仅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之"文件上传"

<form name="UploadForm" enctype="multipart/form-data" method="post" action="upLoadImage.do">
<input type="file" name="File1" size="11" maxlength="20"/><input type="submit"value="上 传"/>
</form>  
  String path="images\\product\\";
String temp=thi ......

Java用AWT实现的状态栏

      AWT中没有提供状态栏工具,可以在Frame中添加一个Panel实现类似的功能。基本功能有创建状态栏,添加指示器,移除指示器,改变指示器内容,获得指示器内容,添加指示器鼠标消息响应,添加指示器右键弹出菜单,获得对一个指示器的引用等。
import java.awt.Color;
import java.awt.Componen ......

Java 串匹配Brute Force算法

每天基础(1),串匹配之Brute-Force算法,最简单的遍历算法。另外有KMP算法,是对此算法的改进,避免每次比较都回回退。
package ibees.sample;
/**
* 字符串匹配模式算法Brute-Force算法,此算法每次比较都会回退
* @author hhzxj2008
* */
public class StringMatch {

/**
* 相当于java.lang.String的i ......

Flex 对Java端返回Collection的处理方法

将Flex与Spring集成后(BlazeDS 与Spring集成指南 ),第一个面临的问题就是:对于Java端返回的各种Java类型的对象,Flex中能否有相应的数据类型来映射。
处理,尤其是List、Set、Map及POJO对象值。
在 BlazeDS 与Spring集成指南 例子的基础上,调整相关的测试代码如下:
1、Java端
1.1、com.yeeach.HelloWorldService ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号