Java Byte Array Create toBytesFromASCII(final char[] chars)

Here you can find the source of toBytesFromASCII(final char[] chars)

Description

to Bytes From ASCII

License

Open Source License

Declaration

public static byte[] toBytesFromASCII(final char[] chars) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015, 2017 Lablicate GmbH.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*w w w  .  j  a v a2s .c o m*/
 * Dr. Alexander Kerner - initial API and implementation
 *******************************************************************************/

public class Main {
    public static byte[] toBytesFromASCII(final char[] chars) {

        final byte[] b = new byte[chars.length];
        for (int i = 0; i < b.length; i++) {
            b[i] = (byte) chars[i];
        }
        return b;
    }
}

Related

  1. toBytes4HexString(String str, char... separateds)
  2. toBytesBE(long v)
  3. toBytesBigEndian(long value, int sizeInByte)
  4. toBytesBinary(String in)
  5. toBytesDirect(final String singleOctets)
  6. toBytesFromBase64(String inBase64String)
  7. toBytesFromBin(String binSymbols)
  8. toBytesFromHexStr(String hexStr)
  9. toBytesFromHexString(String digits)