In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to use java to deal with the function of characters". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. GetBytes is a standard function for java string processing, and its function is to represent the characters represented by the charset encoded string in bytes.
Note: strings are always stored in unicode encoding in java memory.
2. NewString combines and identifies the byte array according to charset coding and converts it to unicode storage.
3. SetCharacterEncoding ()
This function is used to set the http request or the corresponding encoding.
Example
Package com.test.bs; import java.io.UnsupportedEncodingException; public class UnicodeTest2 {public static void main (String [] args) {String a = ""; try {byte [] gb2312 = a.getBytes ("GB2312"); byte [] utf = a.getBytes ("UTF-8"); for (int I = 0; I < gb2312.length; ionization +) {System.out.print (gb2312 [I]);} System.out.println (); for (int I = 0; I < utf.length) ITunes +) {System.out.print (UTF [I]);} System.out.println (); System.out.println (new String (gb2312)); System.out.println (new String (utf)); System.out.println (System.getProperty ("file.encoding")); / / current file encoding method System.out.println (new String (utf, "UTF-8")); System.out.println (new String (gb2312, "UTF-8")) } catch (UnsupportedEncodingException e) {e.printStackTrace ();} "the function of how to use java to handle characters" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 300
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.