Java ASCII to String asciiBytesToString(byte[] val)

Here you can find the source of asciiBytesToString(byte[] val)

Description

Convert a byte array to a String assuming the ASCII character set, for use in cases (such as early in the boot process) where character set conversion is unavailable or inadvisable.

License

Common Public License

Parameter

Parameter Description
val Byte array to convert

Return

The resulting string

Declaration

public static String asciiBytesToString(byte[] val) 

Method Source Code

//package com.java2s;
/*/*w w  w .j  av  a  2s .co m*/
 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
 *
 *  This file is licensed to You under the Common Public License (CPL);
 *  You may not use this file except in compliance with the License. You
 *  may obtain a copy of the License at
 *
 *      http://www.opensource.org/licenses/cpl1.0.php
 *
 *  See the COPYRIGHT.txt file distributed with this work for information
 *  regarding copyright ownership.
 */

public class Main {
    /**
     * 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);
    }
}

Related

  1. ascii2Str(String s)
  2. ascii2String(String ASCIIs)
  3. asciiBytesToChar(byte[] bytes)
  4. ASCIIToChar(final int ascii)
  5. AsciiToChar(int asc)
  6. asciiToLowerCase(String s)
  7. asciiToString(byte ascii)