Java Char to Byte convertCharToByte(char[] source, int srclen)

Here you can find the source of convertCharToByte(char[] source, int srclen)

Description

convert Char To Byte

License

LGPL

Declaration

public static byte[] convertCharToByte(char[] source, int srclen) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] convertCharToByte(char[] source, int srclen) {
        if (source == null) {
            return null;
        }//from w w  w  .  j a  va 2  s  .  co  m

        int len = source.length;
        if (len > srclen) {
            len = srclen;
        }
        byte[] dest = new byte[len];
        for (int i = 0; i < len; i++) {
            dest[i] = (byte) source[i];
        }
        return dest;
    }
}

Related

  1. charToByte(char[] tab)
  2. charToByte(char[] values)
  3. charToByte(final char value)
  4. convertCharToByte(char firstChar, char secondChar)
  5. convertCharToByte(char[] from)
  6. convertCharToBytes(char c)