Java Char Array to Byte Array char2byte(char[] chars, int offset, int len, byte[] result, int roffset)

Here you can find the source of char2byte(char[] chars, int offset, int len, byte[] result, int roffset)

Description

charbyte

License

Open Source License

Declaration

public static final void char2byte(char[] chars, int offset, int len, byte[] result, int roffset) 

Method Source Code

//package com.java2s;
/*//ww w.  j  a va  2s  . c  o  m
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

public class Main {
    public static final byte[] char2byte(char[] chars, int offset, int len) {
        byte[] result = new byte[len];
        char2byte(chars, offset, len, result, 0);
        return result;
    }

    public static final void char2byte(char[] chars, int offset, int len, byte[] result, int roffset) {
        for (int i = 0; i < len; i++)
            result[roffset + i] = (byte) chars[offset + i];
    }
}

Related

  1. charArrayToByteArray(char charBuf[])
  2. charArrayToByteArray(char[] c)
  3. charArrayToByteArray(char[] value)
  4. charArrayToByteArray(final char[] message)