java resource
1517 ワード
package com.xm.resource;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
public class TestLocal {
public static void main(String args[]) throws IOException{
Locale locale=new Locale("en","","");
System.out.println(locale.getLanguage());
System.out.println(locale.getCountry());
System.out.println(locale.getVariant());
ResourceBundle resource=ResourceBundle.getBundle("com.xm.resource.resource",locale);
System.out.println(resource.getString("name"));
Properties property=new Properties();
property.load(new FileInputStream("src//com//xm//resource//resource_zh.properties"));
System.out.println(property.get("name"));
HashMap map=new HashMap(property);
System.out.println(map.get("name"));
property.store(new FileOutputStream("c://test.properties"), " ");
String pattern="{0} {1} ";
Object[] params={"TestLocal","main"};
String resourceString = MessageFormat.format(pattern, params);
System.out.println(resourceString);
}
}