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(
Ïà¹ØÎĵµ£º
01¡¢ÈÿؼþµÃµ½½¹µã
ÓÃ.requestFocus();¿ÉÒÔ»ñµÃ¿Ø¼þ½¹µã¡£
nextFocus()Ôò¿É½øÈëÏÂÒ»¸ö½¹µã¡£
02¡¢½«StringÀàÐÍתΪintÀàÐÍ
Integer.parseInt(String);
03¡¢½«IntegerÀàÐÍתΪStringÀàÐÍ
String.valueOf(Integer); ......
½øÒ»·¨£º ¼´Ê¡ÂÔµÄλÉÏÖ»Òª´óÓÚÁ㶼Ҫ½øһλ £»
ËÄÉáÎåÈë·¨£º ¼´Ê¡ÂÔµÄλÉÏСÓÚÎ嶼ҪÉáÈ¥£¬µ«Ê¡ÂÔµÄλÉÏÂúÎ嶼Ҫ½øһλ £»
»¹ÓÐÒ»ÖÖ
ȥβ·¨£º ¼´Ê¡ÂÔµÄλÉϲ»¹ÜÊÇ·ñÂúÎ嶼ҪÉáÈ¥ £»
1¡¢³ý·¨´øСÊý
ÀýÈ磺
int a = 8;
int b = 3;
int c = ((double)la)/b;
System.out.println(c); ......
ÔÎĵØÖ·£º http://www.javaworld.com/javaworld/jw-09-2007/jw-09-optimizingregex.html
Èç¹ûÄ㻨·ÑÁËÊýСʱºÍÕýÔò±í´ïʽ×ö¶·Õù£¬Ö»ÊÇΪÁËÈÃËüÍê³ÉËü¼¸ÃëÄھͿÉÒÔÍê³ÉµÄÆ¥Å䣬ÄÇôÕâƪÎÄÕÂÕýÊÇΪÄãÁ¿Éí¶¨×öµÄ¡£Cristian
MocanuÖ¸³öÁËÔÚʲôµØ·½ÕýÔòģʽƥÅä»á·¢ÉúÑÓ³Ù ......
Hibernate Ö®¸¸ Gavin King[1]½¨Ò鿪·¢ÕßÉý¼¶µ½ Java EE 6 ƽ̨£¬²¢Ö¸³ö£¬Ä¿Ç°¸÷ÖÖ²»Ô¸ÒâÉý¼¶µÄ¹ÛµãÆäʵÊÇûÓиù¾ÝµÄ¡£
Java EE 6 ·¢²¼ºó£¬ÎÒ¿´µ½Á˺ܶ෴¶ÔÉý¼¶µ½ÐÂƽ̨µÄ¹Ûµã¡£ÕâЩ·´¶Ô¹Ûµã´ó¶àÊÇÓÉ Tomcat / Jetty ÒÔ¼°Ò»Ð©¿ªÔ´¿ò¼Ü£¨ÀýÈç Hibernate Óë Spring£©µÄʹÓÃÕßÌá³ö¡£
µ±È»£¬Ñ¡Ôñ·Ç±ê×¼¡¢¿ªÔ´¼¼ÊõÓкܶàºÃ´¦¡ ......
±¾ÎÄÖ÷Ҫ̸һÏÂÃÜÂëѧÖеļÓÃܺÍÊý×ÖÇ©Ãû£¬ÒÔ¼°ÆäÔÚjavaÖÐÈçºÎ½øÐÐʹÓ᣶ÔÃÜÂëѧÓÐÐËȤµÄ»ï°é£¬ÍƼö¿´Bruce SchneierµÄÖø×÷£ºApplied Crypotography¡£ÔÚjdk1.5µÄ·¢Ðа汾Öа²È«ÐÔ·½ÃæÓÐÁ˺ܴóµÄ¸Ä½ø£¬Ò²ÌṩÁ˶ÔRSAËã·¨µÄÖ±½ÓÖ§³Ö£¬ÏÖÔÚÎÒÃÇ´ÓʵÀýÈëÊÖ½â¾öÎÊÌ⣨±¾ÎĽöÊÇ×÷Ϊ¼òµ¥½éÉÜ£©£º ......