易截截图软件、单文件、免安装、纯绿色、仅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常用方法

01、让控件得到焦点
    用.requestFocus();可以获得控件焦点。
    nextFocus()则可进入下一个焦点。
02、将String类型转为int类型
    Integer.parseInt(String);
03、将Integer类型转为String类型
    String.valueOf(Integer); ......

Java三十个目标

1.你需要精通面向对象分析与设计(OOA/OOD)、涉及模式(GOF,J2EEDP)以及综合模式。你应该十分了解UML,尤其是class,object,interaction以及statediagrams。

  2.你需要学习JAVA语言的基础知识以及它的核心类库
(collections,serialization,streams,networking,  
multithreading,reflection,event,h ......

优化Java动画编程中的显示效果

Java动画编程有多种实现方法,但它们实现的基本原理是一样的,即在屏幕上画出一系列的帧来造成运动的感觉。Java多线程技术是Java动画编程中普遍运用的技术,它在控制动画程序的流程和动画的显示效果方面起着重要的作用。Java动画编程中的动画闪烁和图像残缺不全等现象,是Java程序员经常遇到的问题。本文以作者应用实例程序 ......

Java中文字符转换拼音

将传入的任意中文字符转换为拼音
(1)多音字只取其中一个读音。
(2)生僻字如果没有拼音,使用unknown替代。
package com.amgotech;
public class ChineseSpelling
 {
   private static int[] pyvalue = new int[] { -20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号