Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java ¶ÁÈ¡ÊôÐÔÎļþ

// messages.hello.properties
id=001
name=ϧԵ
love=I think,therefor i am.
friends=Hi! {0} and {1} ,how are you?
// org.PropertiesUtil.java
package org;
import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class PropertiesUtil {
private static String encoding = "UTF-8";
/**
* read the message with key from the resource bundle
* @param bundlePath
* @param key
* @return
*/
public static String getString(String bundlePath,String key){
return getString(bundlePath,key,null);
}
/**
* read the message with key from the resource bundle
* @param bundlePath
* @param key
* @param args
* @return
*/
public static String getString(String bundlePath,String key,Object[] args){
// we will throw a MessingResourceException if the bundle name is invalid
ResourceBundle bundle = getBundle(bundlePath);
try{
String msg = bundle.getString(key);
if(msg == null){
return "";
}
// change the message encoding
msg = convertISO(msg);
return msg = MessageFormat.format(msg, args);
} catch(MissingResourceException e){
return "";
}
}
/**
* get ResourceBundle with bundlePath
* @param bundlePath
* @return
* @throws MissingResourceException if resource is messing
*/
private static ResourceBundle getBundle(String bundlePath){
Locale locale = Locale.getDefault();
ResourceBundle bundle = ResourceBundle.getBundle(bundlePath,locale,getClassLoader());
return bundle;
}
/**
* get the current ClassLoader
* @return
*/
protected static ClassLoader getClassLoader(){
return PropertiesUtil.class.getClassLoader();
}
/**
* convert msg encoding
* @param msg
* @return
*/
public static String convertISO(String msg){
if(msg != null){
try{
return new String(msg.getBytes("iso-8859-1"),getEncoding());
} catch(


Ïà¹ØÎĵµ£º

javaÖеÄSystem.currentTimeMillis()º¯Êý

System.currentTimeMillis()£º¿ÉÒÔÌáÈ¡µ½µ±Ç°Ê±¼äµÄºÁÃëÊý£¬²úÉúÒ»¸öµ±Ç°µÄºÁÃ룬Õâ¸öºÁÃëÆäʵ¾ÍÊÇ×Ô1970Äê1ÔÂ1ÈÕ0ʱÆðµÄºÁÃëÊý¡£
³£¼û×÷ÓãºÒ»°ã¶¼ÊÇÓÃ2¸öʱ¼äµÄ²îÖµÀ´µÃµ½ÔËÐÐʱ¼äµÄ£¬³£ÓÃÀ´±È½Ï2¸öËã·¨µÄЧÂÊ£¡
long start = System.currentTimeMillis();
  // ÕâÀï¿ÉÒÔ¼ÓÉÏÄãÒªÖªµÀµÄ·½·¨ÔËÐеÄʱ¼ä£¡£¡
......

javaÉú³ÉËæ»úÊý×ÖºÍ×Öĸ×éºÏ


×¢£º1.·½·¨µÄ²ÎÊý length ÊÇÉú³ÉµÄËæ»úÊýµÄ³¤¶È¡£
      2. Ö»ÏëÒª´óдµÄ×Öĸ ¿ÉÒÔʹ int choice =65£» Ö»ÏëҪСдµÄ×Öĸ£¬¾Í int choice =97£»
import java.util.Random;
public String getCharAndNumr(int length)  
{  
    String val = " ......

HibernateÖ®¸¸£º¸ÃÉý¼¶µ½Java EE 6ÁË

Hibernate Ö®¸¸ Gavin King[1]½¨Ò鿪·¢ÕßÉý¼¶µ½ Java EE 6 ƽ̨£¬²¢Ö¸³ö£¬Ä¿Ç°¸÷ÖÖ²»Ô¸ÒâÉý¼¶µÄ¹ÛµãÆäʵÊÇûÓиù¾ÝµÄ¡£
Java EE 6 ·¢²¼ºó£¬ÎÒ¿´µ½Á˺ܶ෴¶ÔÉý¼¶µ½ÐÂƽ̨µÄ¹Ûµã¡£ÕâЩ·´¶Ô¹Ûµã´ó¶àÊÇÓÉ Tomcat / Jetty ÒÔ¼°Ò»Ð©¿ªÔ´¿ò¼Ü£¨ÀýÈç Hibernate Óë Spring£©µÄʹÓÃÕßÌá³ö¡£
µ±È»£¬Ñ¡Ôñ·Ç±ê×¼¡¢¿ªÔ´¼¼ÊõÓкܶàºÃ´¦¡ ......

javaµÄMD5¼ÓÃÜÓë½âÃÜ

·½·¨Ò»£ºÖ»¼ÓÃÜ
import java.security.*;  
import java.security.spec.*;  
 
class MD5_test {  
 public final static String MD5(String s) {  
  char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',  
 &n ......

javaº¯ÊýµÄ²ÎÊý´«µÝºÍStringÀàÐÍ

ÒÔÏÂÄÚÈÝÕª×Ôjavaº¯ÊýµÄ²ÎÊý´«µÝºÍStringÀàÐÍ http://www.blogjava.net/thuixy/archive/2009/06/06/280302.html
˵ÍêÁËjavaµÄStringÀàÐÍ£¬ÎÒÃÇ×îºó¿´¿´javaº¯Êý²ÎÊýµÄ´«µÝ£¬µ½µ×ÊÇÖµ´«µÝ»¹ÊÇÒýÓô«µÝÄØ£¿Ò»°ãµÄ˵·¨ÊǶÔÓÚ»ù±¾ÀàÐͱÈÈçint¡¢charÊÇÖµ´«µÝ£¬¶ÔÓÚ¶ÔÏóÀàÐÍÊÇÒýÓô«µÝ¡£ÕâÖÖ˵·¨Ã»´í£¬µ«ÊÇÇë¿´ÏÂÃæµÄÀý×Ó£º
Str ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ