In the process of development, character encoding often gives us headaches. Often there are a variety of garbled characters. The following is the introduction of Java Encoding conversion and common garbled is what encoding to use to read:
First look at a picture:
Look at how the encoded transformation is handled in Java:
Package com.test;/** * String encoding conversion * @author Herman.xiong * @date July 16, 2015 09:36:59 * @version V3.0 * @since tomcat6.0,jdk1.6 * @copyright Copyright (c) */public class Httpserverdecoder {public static void main (string[] args) throws Exception {String str= Welcome to join the request group: 454796847 Learn together! "; System.out.println (str);//Convert to Utf-8 output System.out.println (new String (. GetBytes ("Utf-8"));// Convert to GBK output System.out.println (new string (. GetBytes ("GBK"));//Convert Iso-8859-1 to Utf-8system.out.println (new string ( Str.getbytes ("Iso-8859-1"), "Utf-8");}}
Welcome everyone to follow my blog! If in doubt, please add QQ Group: 454796847 Study together!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java character encoding conversion