随笔分类 -  java

摘要:InetAddress[] arr = InetAddress.getAllByName("www.qq.com");for(InetAddress addr :arr) { if(addr instanceof Inet4Address) { System.out.println("ipv4 : "+addr.getHostAddress()); } else if(addr instanceof Inet6Address){ System.out.println("ipv6 : "+addr.getHostAddress()); 阅读全文
posted @ 2012-12-03 17:49 悟寰轩-叶秋 阅读(308) 评论(0) 推荐(0)
摘要:转自:http://www.cnblogs.com/cuizhf/archive/2011/08/22/2150046.htmlenum与int、String之间的转换enum<->intenum->int:int i=enumType.value.ordinal();int->enum:enumTypeb=enumType.values()[i];enum<->Stringenum -> String: enumType.name()String -> enum: enumType.valueOf(name);----------------- 阅读全文
posted @ 2012-12-03 17:30 悟寰轩-叶秋 阅读(27173) 评论(0) 推荐(0)
摘要:Java中getResourceAsStream的用法首先,Java中的getResourceAsStream有以下几种:1. Class.getResourceAsStream(String path) : path 不以’/'开头时默认是从此类所在的包下取资源,以’/'开头则是从ClassPath根下获取。其只是通过path构造一个绝对路径,最终还是由ClassLoader获取资源。2. Class.getClassLoader.getResourceAsStream(String path) :默认则是从ClassPath根下获取,path不能以’/'开头,最终是 阅读全文
posted @ 2012-12-03 17:28 悟寰轩-叶秋 阅读(158) 评论(0) 推荐(0)
摘要:1,定时凌晨1点执行(由于Quartz 2.0和spring目前版本不兼容,所以采取如下方法,不知道spring3.2会不会修复这个bug) public void doTask(CheckSpiderService doCheck) {// 获取当前时间Calendar currentDate = Calendar.getInstance();long currentDateLong = currentDate.getTime().getTime();// 计算满足条件的最近一次执行时间Calendar earliestDate = getEarliestDate(currentDate.. 阅读全文
posted @ 2012-12-03 17:25 悟寰轩-叶秋 阅读(785) 评论(1) 推荐(0)
摘要:1 import java.awt.Image; 2 import java.awt.image.BufferedImage; 3 import java.io.File; 4 import java.io.FileOutputStream; 5 import java.io.IOException; 6 7 import javax.imageio.ImageIO; 8 9 import org.slf4j.Logger;10 import org.slf4j.LoggerFactory;11 12 import com.sun.image.codec.jpeg.JPEGCodec;1... 阅读全文
posted @ 2012-12-03 17:23 悟寰轩-叶秋 阅读(1528) 评论(0) 推荐(0)
摘要:RandomStringUtils随机RandomCommons-lang//产生12位长度的随机字符串RandomStringUtils.random(12);//使用指定的字符生成3位长度的随机字符串RandomStringUtils.random(3, new char[]{'a','b','c','d','e','f,'g'});//生成指定长度的字母和数字的随机组合字符串RandomStringUtils.randomAlphanumeric(12);//生成随机数字字符串Rand 阅读全文
posted @ 2012-12-03 17:17 悟寰轩-叶秋 阅读(335) 评论(0) 推荐(0)