Java ASCII from toASCII(String str)

Here you can find the source of toASCII(String str)

Description

to ASCII

License

Open Source License

Declaration

public static String toASCII(String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String toASCII(String str) {
        StringBuffer strBuf = new StringBuffer();
        byte[] bGBK = str.getBytes();
        for (int i = 0; i < bGBK.length; i++) {
            strBuf.append(Integer.toHexString(bGBK[i] & 0xff));
        }/*from www  . ja va 2s.  c o  m*/
        return strBuf.toString();
    }

    public static String toString(Object object) {
        return toString(object, null);
    }

    public static String toString(Object object, String defaultValue) {
        if (object == null)
            return defaultValue;
        return String.valueOf(object);
    }
}

Related

  1. toAscii(String notAscii)
  2. toAscii(String s)
  3. toAscii(String s)
  4. toASCII(String s)
  5. toAscii(String s)
  6. toAsciiArray(char[] carr)
  7. toAsciiByteArray(final char[] carr)
  8. toAsciiByteArray(String s)
  9. toAsciiBytes(final String value)