Java - Write code to Convert a byte array to a String assuming the ASCII character set

Requirements

Write code to Convert a byte array to a String assuming the ASCII character set

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        byte[] val = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(asciiBytesToString(val));
    }/*  ww w  .j a  va 2 s  .c o  m*/

    /**
     * Convert a byte array to a <code>String</code> assuming the ASCII
     * character set, for use in cases (such as early in the boot process)
     * where character set conversion is unavailable or inadvisable.
     *
     * @param val Byte array to convert
     * @return The resulting string
     */
    public static String asciiBytesToString(byte[] val) {
        return asciiBytesToString(val, 0, val.length);
    }

    /**
     * Convert a byte array to a <code>String</code> assuming the ASCII
     * character set, for use in cases (such as early in the boot process)
     * where character set conversion is unavailable or inadvisable.
     *
     * @param val Byte array to convert
     * @param start Start the string at this byte
     * @param length Use 'length' bytes
     * @return The resulting string
     */
    @SuppressWarnings("deprecation")
    public static String asciiBytesToString(byte[] val, int start,
            int length) {
        return new String(val, 0, start, length);
    }
}