Java Chinese and ASCII code conversion __android

Source: Internet
Author: User
Tags stringbuffer

Today, when I was coding in Java, I saw the power of ASCII code in Java. Wrote a Coderutils.java and will expand it later.

[Java]  View plain copy package com.xingxd.study.test;      import java.io.file;    import java.io.filewriter;   import java.io.ioexception;   import  java.io.printwriter;     /**   *  @date  2009-3-11   * @ author xing,xiudong   *  @Email:xingxiuodng[at]gmail.com   *  @index: http:// blog.csdn.net/xxd851116   */   public class coderutils {           public static char ascii2char (INT&NBSP;ASCII)  {           return  (char)  ASCII;        }          public static int char2ascii (char c )  {           return  (int)  c;       }          public static String  Ascii2string (int[] asciis)  {           stringbuffer  sb = new stringbuffer ();           for   (int i = 0; i < asciis.length; i++)  {                sb.append ((char)  ascii2char (ASCIIs[i));            }            return sb.tostring ();       }           public static string ascii2string (String asciis)  {           string[] asciiss = asciis.split (",");            stringbuffer sb = new stringbuffer ();            for  (int i = 0; i < asciiss.length;  i++)  {               sb.append ((char)  ascii2char (Integer.parseint (asciiss[i)));            }           return sb.tostring ();       }          public static int[]  String2ascii (string s)  {//  string conversion to ASCII             if  (s == null | |   "". Equals (s))  {                return null;           }              char[] chars = s.tochararray ( );           int[] asciiarray = new int[ chars.length];  

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.