导航

2011年7月13日

摘要: 最近接手了一个堪称经典浆糊的项目,其中一个bug折腾了我好久也没能从根本上解决, 它总是在某些机器某些时候是好的,在另一个地方另一个时间也许就又出现了。经过我不断的debug和测试最后发现问题的根源在于java的一个 bug:Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); 这个代码根 本就是不可靠的。于是到网上一搜,我靠,这个bug从2001年的jdk1.3一直到现在也没被修复! 原来sun公司也是这样,于是我心里也算多了些许安慰。。。java的这个bug链接:http://bugs.sun.com/ 阅读全文

posted @ 2011-07-13 14:45 teasp 阅读(423) 评论(0) 推荐(0)

2011年3月16日

摘要: 最近写的一个程序要在Linux下用到Runtime.getRuntime().exec(command),可是发现一个奇怪的问题。先看看代码: public static void main(String[] args) { try { String[] command = {"kill", "-9", "`ps -ef | grep '程序名' | awk '{print $2}'`"}; Process p = Runtime.getRuntime().exec(command); p.waitFo 阅读全文

posted @ 2011-03-16 12:26 teasp 阅读(1012) 评论(1) 推荐(0)

2010年9月29日

摘要: 闲话少说,看代码先:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->public class Test { public static void main(String[] args) { Calendar c1 = Calendar.getInstance(); c1.set(2000, 0, 1, 1, 0, 0); //2000年1月1日1点 long l1 = c1.getTimeInMillis(); Calendar c2 = 阅读全文

posted @ 2010-09-29 13:12 teasp 阅读(442) 评论(2) 推荐(1)

2010年7月13日

摘要: 这是在网上找到的一个小例子,关于X Window编程的。那个例子本身无法编译通过,我做了少量的修改使之可以编译并且运行。Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include <stdio.h>#include <unistd.h>#include <X11/Xlib.h>#include <X11/Xmu/WinUtil.h>//#include <X11/Xutil.h> 阅读全文

posted @ 2010-07-13 15:34 teasp 阅读(2645) 评论(0) 推荐(0)

2010年7月12日

摘要: 在当前目录下的所有普通文件中搜索hostnames这个词:# find . -name \* -type f -print | xargs grep “hostnames” 阅读全文

posted @ 2010-07-12 11:02 teasp 阅读(1430) 评论(1) 推荐(0)