Here you can find the source of asciiBytesToChar(byte[] bytes)
Parameter | Description |
---|---|
bytes | the bytes from an ascii encoded text (note - no validation is done to ensure ascii encoding) |
public static char[] asciiBytesToChar(byte[] bytes)
//package com.java2s; //License from project: LGPL public class Main { /**// w ww .ja v a 2s . c om * Converts bytes from ascii encoded text to a char[] and zero outs the original byte[] * * @param bytes the bytes from an ascii encoded text (note - no validation is done to ensure ascii encoding) * @return the corresponding char[] */ public static char[] asciiBytesToChar(byte[] bytes) { char[] chars = new char[bytes.length]; for (int i = 0; i < bytes.length; i++) { chars[i] = (char) bytes[i]; bytes[i] = '\0'; } return chars; } }