Properties Chinese garbled problem __ garbled problem

Source: Internet
Author: User


Reference from: http://www.webkaifa.com/thread-260-1-1.html


/** * Inheritance Properties * @author * @date 2011-11-23/public class Properties extends Java.util.Properties {private STA
	Tic final long serialversionuid = -2357393781665671357l;  private static final String properties_default_encoding = "Iso-8859-1";  JAVA Properties default encoding private String defaultencoding;
	The default encoding/** * */Public Properties () {super ();
		/** * @param defaultencoding Default encoding */Public Properties (String defaultencoding) {this ();
	this.defaultencoding = defaultencoding; }/** * @param defaultproperties Default profile */Public Properties (properties defaultproperties) {Super (Defaultproper
	Ties); /** * @param defaultproperties Default profile * @param defaultencoding default encoding */Public properties (Properties Defaultpro
		Perties, String defaultencoding) {this (defaultproperties);
	this.defaultencoding = defaultencoding; }/* (non-javadoc) * @see java.util.hashtable#get (java.lang.Object)/@Override public synchronized Object get (O Bject keY) {Object ovalue = Super.get (key); if (ovalue!= null && defaultencoding!= null) {if (Ovalue instanceof String) {try {return (Object) NE
				W String (String.valueof (ovalue). GetBytes (properties_default_encoding), defaultencoding);
				catch (Unsupportedencodingexception e) {return ovalue;
	}} return ovalue; /** * The return result of the parent class get is encoded * @author * @date 2011-11-23 * @param key * @param encoding * @return U Nsupportedencodingexception */Public synchronized Object getwithencoding (string key, String encoding) throws Unsupport
		edencodingexception {Object ovalue = This.get (key);
					if (ovalue!= null && encoding!= NULL) {if (Ovalue instanceof String) {if (defaultencoding = null) {
				Return (Object) New String (String.valueof (ovalue). GetBytes (properties_default_encoding), ENCODING);
				else {return (Object) New String (String.valueof (ovalue). GetBytes (defaultencoding), encoding); }}} RetuRN Ovalue; }/* (non-javadoc) * @see java.util.properties#getproperty (java.lang.String)/@Override public String Getproper
		Ty (string key) {String value = Super.getproperty (key); if (value!= null && defaultencoding!= null) {try {return new String (string.valueof (value). GetBytes (Prope
			rties_default_encoding), defaultencoding);
			catch (Unsupportedencodingexception e) {return value;
	} return value; }/* (non-javadoc) * @see java.util.properties#getproperty (java.lang.String, java.lang.String) * * * @Override Publi
		C string GetProperty (string key, String defaultvalue) {String value = This.getproperty (key); return value = = null?
	Defaultvalue:value;
	/** * GetProperty The return result of the parent class * @author * @date 2011-11-23 * @param key * @param encoding * @return * *  public string getpropertywithencoding (string key, String encoding) throws Unsupportedencodingexception {String value =
		This.getproperty (key); if (Value!= nulL && encoding!= null) {if (defaultencoding = null) {return new String (Value.getbytes properties_default_
			ENCODING), ENCODING);
			else {return new String (Value.getbytes (defaultencoding), encoding);
	} return value; /** * GetProperty The return result of the parent class * @author * @date 2011-11-23 * @param key * @param defaultvalue * @param en  Coding * @return * @throws unsupportedencodingexception/public string getpropertywithencoding (string key, String DefaultValue, string encoding) throws Unsupportedencodingexception {String value = this.getpropertywithencoding (Key,
		encoding); return value = = null?
	Defaultvalue:value; }
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.