java
共 7 篇文章
深入理解EventBus的设计思想
凌弃同学已经介绍了EventBus的使用方式 如何使用——三步走: 1、定义一个observer,并加入@Subscribe作为消息回调函数; 2、将observer注册到EventBus;EventBus.register(this); 3、消息投递: eventBus.post(logTo); 本文将深入EventBus的源代码,和大家一起深入研究EventBus的让人惊叹的设计思路。由于作者水平有限,无法面面俱到,希望大家先读读 EventBusExplained 。 注:Guava的版本 <dependency> <groupId>com.google.guava</group…
2013-12-03 10:08 · java
关于classpath wildcard
在java 1.5的时候,我还得写bash脚本去loop获得所有的jar,然后写到classpath下面,现在换到1.6,发现有个classpath wildcard,原来classpath也有通配符 看 这里 Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For exam…
2011-04-22 15:37 · java
mark一句话
Working as an effective professional Java developer requires two major skills: thinking like a Java developer and having a broad understanding of Java APIs, tools, and techniques to solve a wide variety of Java problems.
2011-04-01 15:51 · java
为神马 1.0 - 0.7 != 0.3 ???
直接上代码 public static void main(String[] args) { System.out.println(1.0 - 0.1); System.out.println(1.0 - 0.2); System.out.println(1.0 - 0.3); System.out.println(1.0 - 0.4); System.out.println(1.0 - 0.5); System.out.println(1.0 - 0.6); System.out.println(1.0 - 0.7); System.out.println(1.0 - 0.8); Syst…
2011-01-21 23:54 · java
Runtime.getRuntime().exec(...)使用方法
上两周问答大赛的时候,看到了很多人问为什么自己调用的Runtime.getRuntime().exec(...)方法没有返回。其实没有返回的原因很多,但是前提你要写出一个正确的exec 如果想要了解更多的信息,参阅代码里面给的链接 下面是这个正确的例子 public class RuntimeExec { /** * Runtime execute. * * @param cmd the command. * @return success or failure * @see {@link http://www.javaworld.com/javaworld/jw-12-2000/jw-12…
2011-01-15 22:49 · java
the webapp configuration of jetty + spring + db
自己留作一个备份,share给大家 maven-webapp的pom.xml,关于jetty + spring + bonecp的配置 不过前提是你要懂一点点maven <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apa…
2011-01-15 22:39 · java
Gregorian Calendar ------ 有趣的日历
项目有个需求,每天生成一个文件。开始觉得用一个 TimeTask 或者 ScheduledThreadPoolExecutor 或者 quartz 来做,突然觉得太overweight了。后来想到了log4j的 DailyRollingFileAppender ,果然是我想要的,类似于quartz,通过与类似nextFireTime的参数作比较,判断是否触发append到新文件,不过这不是这篇博文要讲的。我有注意到了这个类,在DailyRollingFileAppender有个inner class RollingCalendar。 这个类的作用也说明了,是 computes the sta…
2010-12-01 13:50 · java