Here you can find the source of toBytesFromASCII(final char[] chars)
public static byte[] toBytesFromASCII(final char[] chars)
//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; } }