获取普通Java对象大小
缓存对象需要知道对象占用空间的大小,可以事先设置好每种类型的大小,此方法对普通的对象起效,Jive论坛中的对象也是采用这种办法来获取对象的大小的(取自Jive).
public class CacheSizes {
/**
* Returns the size in bytes of a basic Object. This method should only
* be used for actual Object objects and not classes that extend Object.
*
* @return the size of an Object.
*/
public static int sizeOfObject() {
return 4;
}
/**
* Returns the size in bytes of a String.
*
* @param string the String to determine the size of.
* @return the size of a String.
*/
public static int sizeOfString(String string) {
if (string == null) {
return 0;
}
return 4 + string.length()*2;
}
/**
* Returns the size in bytes of a primitive int.
*
* @return the size of a primitive int.
*/
public static int sizeOfInt() {
return 4;
}
/**
* Returns the size in bytes of a primitive char.
*
* @return the size of a primitive char.
*/
public static int sizeOfChar() {
return 2;
}
/**
* Returns the size in bytes of a primitive boolean.
*
* @return the size of a primitive boolean.
*/
public static int sizeOfBoolean() {
return 1;
}
/**
* Returns the size in bytes of a primitive long.
*
* @return the size of a primitive long.
*/
public static int sizeOfLong() {
return 8;
}
/**
* Returns the size in bytes of a primitive double.
*
* @return the size of a primitive double.
*/
public static int sizeOfDouble() {
return 8;
}
/**
* Returns the size in bytes of a Date.
*
* @return the size of a Date.
*/
public static int sizeOfDate() {
return 12;
}
/**
* Returns the size in bytes of a Properties object
相关文档:
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......
Java 数据流2(PipedInputStream,PipedOutputStream...)
2007-08-18 17:30
字节流的高级应用
? 管道流
管道用来把一个程序、线程和代码块的输出连接到另一个程序、线程和代码块的输入。java.io中提供了类PipedInputStream和PipedOutputStream作为管道的输入/输出流
管道输入流作 ......
一前提:为了方便管理在实际的生产环境一般将weblogic server启动脚本改为后台自动运行并将其输出重定向到指定文件"nohup sh startWeblogicServer.sh>ws.log",之后我们执行kill命令产生的dump信息会保存在ws.log内
二执行:在不同的系统中执行命令不同
......
LDAP是标准轻量目录访问协议(Lightweight Directory Access Protocol),通过LDAP,你可以访问目录中的用户信息,进行用户验证。DominoR5/6支持标准的LDAP v3目录服务。本文通过描述使用JNDI访问Domino目录的过程,为大家介绍如何充分利用机构中已有的Domino目录资源。本文所述的方法也适用于其他支持LDAP v3的目录服务器。
......
Is there a Push-based/Non-blocking XML Parser for Java?
http://stackoverflow.com/questions/1023759/is-there-a-push-based-non-blocking-xml-parser-for-java
http://old.nabble.com/parsing-an-xml-document-chunk-by-chunk-td22945319.html
http://markmail.org/message/ogqqcj7dt3lwkbov ......