`
wen866595
  • 浏览: 264453 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论
文章列表
以前虽然知道在try finally语句中,即使try块里有return语句,finally语句也会在return语句执行之前执行,却不知道return表达式与finally语句的执行顺序。 public class Test { public static int a() { int i = 0; try { i++; return ++i; } finally { i++; } } public static void main(String[] args) { System.out.print ...
当JVM执行一个方法时,执行中的线程识别该方法的method_info结构是否有ACC_SYNCHRONIZED标记设置,然后它自动获取对象的锁,调用方法,最后释放锁。如果有异常发生,线程自动释放锁。 同步化一个方法块会超过JVM对获取对象锁和异常处理的内置支持,要求以字节代码显式写入功能。如果使用同步方法读取一个方法的字节代码,就会看到有十几个额外的操作用于管理这个功能。 public class Sync { private int i; public synchronized int synchronizedMethodGet() { return i; ...
使用JNA简单调用DLL里的函数 1、在VC下创建一个动态链接库项目testJNA 2、在头文件里声明函数 extern "C" _declspec(dllexport) int add(int first, int second); 红色字体部分是必须的,包括定义结构体时也需要。应该是说此函数是发布的。 3、在源码里实现函数 int add(int first, int second) { printf("(c) test jna : %d + %d = %d", first, second, first + second); ...
1、编写需要使用Jni的Java类文件 public class JniCall { static { System.loadLibrary("testJNA"); } public native static int add(int first, int second); public static void main(String[] args) { int first = 3; int second = 4; System.out.printf("print in java : %d + %d = ...
计算一个整数中位为1的位数: public class BitCount { public static int bitCount(int x) { if(x == 0) { return 0; } if(x < 0) { x = -x; } int count = 1; while((x &= (x - 1)) != 0) { count++; } return count; } public static void main(String[] args) ...
关于JDBC 读取SQL Server存储过程的多个结果集来生成报表的解决方法,以前的一位同事已解决了,还写了文章发出来,被引用了很多次!只是自己觉得他写的代码比较复杂,意图也不够清晰,所以仔细阅读了jdk的API文档,给出下面的代码, DBConn = db.connectjdbc(Database); stmt = DBConn.prepareCall(SQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.executeQuery(); do { if ((RS = stmt.getResult ...
最近在弄发传真的,一直在研究怎么把word文档、pdf文件等等转换为tiff文件。因为虚拟打印机可以设置为打印到tiff文件,所以主要难在不知道如何打印这些格式的文件,走了很多弯路:word文档用了jcob来调用MS Office,也研究过永中Office,甚至PWS的个人版,但都觉得调用麻烦;pdf用dos命令来实现静默打印,但考虑到要部署在linux环境,也不爽啊。今天有点空,又继续找,找啊找啊找,不知怎么的看到了Desktop这个类,不熟悉!!!打开API一查,泪奔啊!!! 支持的操作包括: 启动用户默认浏览器来显示指定的 URI; 启动带有可选 mailto URI 的用户默认邮件 ...
Global site tag (gtag.js) - Google Analytics