¼¸ÖÖ¶ÁÈ¡ÊôÐÔÎļþµÄJAVAʵÏÖ·½Ê½
1.ʹÓÃjava.util.PropertiesÀàµÄload()·½·¨
¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡2.ʹÓÃjava.util.ResourceBundleÀàµÄgetBundle()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());
¡¡¡¡
¡¡¡¡3.ʹÓÃjava.util.PropertyResourceBundleÀàµÄ¹¹Ô캯Êý¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = new BufferedInputStream(new FileInputStream(name));
¡¡¡¡ResourceBundle rb = new PropertyResourceBundle(in);
InputStream in = new BufferedInputStream(new FileInputStream(name));
¡¡¡¡ResourceBundle rb = new PropertyResourceBundle(in);
¡¡¡¡
¡¡¡¡4.ʹÓÃclass±äÁ¿µÄgetResourceAsStream()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = JProperties.class.getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = JProperties.class.getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡5.ʹÓÃclass.getClassLoader()ËùµÃµ½µÄjava.lang.ClassLoaderµÄgetResourceAsStream()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡6.ʹÓÃjava.lang.ClassLoad
Ïà¹ØÎĵµ£º
ÕâÆªÎÄÕºÍSUN¹«Ë¾ÌṩµÄ½Ì³ÌÀàËÆ£¬Öмä¶àÁËÒ»¸öHelloImplµÄjavaÎļþ£¬±àÒëʱµÄÃüÁîÒ²¾ÍÓÐËù²»Í¬ÁË
ÔÀ´µÄÃüÁîΪ£ºServer javac HelloServer.java HelloApp/*.java
......
/*
* EncryptUtils.java
* Copyright (C) 2007-3-19 <JustinLei@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* ......
package org.lambdasoft.web.support;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.lambdasoft.web.Enviroment;
public class SessionSupport {
private SessionS ......
ÖÐÎÄÂÒÂë½â¾ö·½°¸£º
Êý¾Ý¿âÂÒÂë:
UTF-8¶ÔÖÐÎÄÓÃ3¸ö×Ö½ÚÀ´±íʾ
String s =”·ÉÏè”;
byte[] utf8 = s.getBytes(“utf-8”);//»ñµÃutf-8±àÂëµÄ×Ö½ÚÖµ
System….(new String(utf8,”gbk”);//ÓÃGBK±àÂë¸ñʽ¶ÔUTF-8±àÂë¸ñʽµÄ×Ö½ÚÊý×é½øÐнâÂ룬½«²úÉúÂÒÂë¡£
²é¿´Êý¾Ý¿âµÄ× ......
ÔÚÏîÄ¿ÖУ¬ÎÒÃǺܶ඼Óõ½ÁËxmlÎļþ£¬ÎÞÂÛÊDzÎÊýÅäÖû¹ÊÇÓëÆäËüϵͳµÄÊý¾Ý½»»¥¡£
½ñÌì¾ÍÀ´½²Ò»ÏÂJava ÖÐʹÓÃdom4jÀ´²Ù×÷XMLÎļþ¡£
ÎÒÃÇÐèÒªÒýÈëµÄ°ü£º
//Îļþ°ü
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
//¹¤¾ß°ü
import java.util.Itera ......