Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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(


Ïà¹ØÎĵµ£º

ubntuÏÂjavaÖÐÎÄÂÒÂë½â¾ö

cd /usr/lib/jvm/java
-1.5.0-sun-1.5.0.15/jre/lib/fonts
sudo mkdir fallback
cd fallback
sudo cp /usr/share/fonts/truetype/arphic/uming.ttc /usr/lib/jvm/java
-1.5.0-sun-1.5.0.15/jre/lib/fonts/fallback
sudo mkfontdir
sudo mkfontscale ......

Javaµ÷ÓÃLinuxÃüÁîÐÐÈô¸ÉʵÀý

 Executing a CommandSee also e90 Reading Output from a Command.
try {
// Execute a command without arguments
String command = "ls";
Process child = Runtime.getRuntime().exec(command);

// Execute a command with an argument
command = "ls /tmp"; ......

²»´íµÄ¾­µäÎÄÕ£ºjavaÌáËÙ

JavaÓïÑÔÌØ±ðÇ¿µ÷׼ȷÐÔ£¬µ«¿É¿¿µÄÐÐΪҪÒÔÐÔÄÜ×÷Ϊ´ú¼Û¡£ÕâÒ»ÌØµã·´Ó³ÔÚ×Ô¶¯ÊÕ¼¯À¬»ø¡¢ÑϸñµÄÔËÐÐÆÚ¼ì²é¡¢ÍêÕûµÄ×Ö½ÚÂë¼ì²éÒÔ¼°±£ÊصÄÔËÐÐÆÚͬ²½µÈµÈ·½Ãæ¡£¶ÔÒ»¸ö½âÊÍÐ͵ÄÐéÄâ»úÀ´Ëµ£¬ÓÉÓÚĿǰÓдóÁ¿Æ½Ì¨¿É¹©ÌôÑ¡£¬ËùÒÔ½øÒ»²½×è°­ÁËÐÔÄܵķ¢»Ó¡£
“ÏÈ×öÍêËü£¬ÔÙÖð²½ÍêÉÆ¡£ÐÒºÃÐèÒª¸Ä½øµÄµØ·½Í¨³£²»»áÌ«¶à¡£”£¨ ......

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

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

Ãô½Ý¿ª·¢Öбàд¸ßÖÊÁ¿Java´úÂë

Ô­Îijö´¦£ºhttp://java.csdn.net/a/20100308/259219.html
Ãô½Ý¿ª·¢µÄÀíÄîÒѾ­Á÷ÐÐÁ˺ܳ¤µÄʱ¼ä£¬ÔÚÃô½Ý¿ª·¢ÖеĿª·¢µü´ú½×¶ÎÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÎå¸ö²½Ö裬À´ÓÐЧµÄÌá¸ßÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿¡£
JavaÏîÄ¿¿ª·¢¹ý³ÌÖУ¬ÓÉÓÚ¿ª·¢ÈËÔ±µÄ¾­Ñé¡¢Java´úÂë±àдϰ¹ß£¬ÒÔ¼°È±·¦Í³Ò»µÄ±ê×¼ºÍ¹ÜÀíÁ÷³Ì£¬ÍùÍùµ¼ÖÂÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿½Ï²î£¬ÄÑÓ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ