易截截图软件、单文件、免安装、纯绿色、仅160KB

获取普通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


相关文档:

Thread Dump 和Java应用诊断(总结版)

一前提:为了方便管理在实际的生产环境一般将weblogic server启动脚本改为后台自动运行并将其输出重定向到指定文件"nohup sh startWeblogicServer.sh>ws.log",之后我们执行kill命令产生的dump信息会保存在ws.log内
二执行:在不同的系统中执行命令不同
           ......

关于java+flex项目欢迎页的问题

开发了个flex和java的测试项目,因为flex文件比较多,所以创建flex时候,
在WebRoot下建立了文件夹bin,用来存储html和swf文件
想在浏览器输入http://localhost:8080/project直接可以访问文件夹下的html
第一,在WebRoot下建立index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
&l ......

认识理解Java中native方法

Java不是完美的,Java的不足除了体现在运行速度上要比传统的C++慢许多之外,Java无法直接访问到操作系统底层(如系统硬件等),为此Java使用native方法来扩展Java程序的功能。
  可以将native方法比作Java程序同C程序的接口,其实现步骤:
  1、在Java中声明native()方法,然后编译;
  2、用javah产生一个.h ......

Java 理论与实践: 正确使用 Volatile 变量

转:http://www.ibm.com/developerworks/cn/java/j-jtp06197.html
2007 年 7 月 05 日
Java™ 语言包含两种内在的同步机制:同步块(或方法)和 volatile 变量。这两种机制的提出都是为了实现代码线程的安全性。其中 Volatile 变量的同步性较差(但有时它更简单并且开销更低),而且其使用也更容易出错。在这期的&nb ......

Java中抽象类和接口的区别

Abstractclass和interface是Java语言中对于抽象类定义进行支持的两种机制,正是由于这两种机制的存在,才赋予了Java强大的面向对象能力。abstractclass和interface之间在对于抽象类定义的支持方面具有很大的相似性,甚至可以相互替换,因此很多开发者在进行抽象类定义时对于abstractclass和interface的选择显得比较随意。其 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号