Java Char to Byte charToByte(char encodedChar)

Here you can find the source of charToByte(char encodedChar)

Description

char To Byte

License

Open Source License

Declaration

private static byte charToByte(char encodedChar) 

Method Source Code

//package com.java2s;
/*/*from   w  w w .  ja  v a2 s. co m*/
 * Copyright (C) 2007 Unicon, Inc.
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this distribution.  It is also available here:
 * http://www.fsf.org/licensing/licenses/gpl.html
 *
 * As a special exception to the terms and conditions of version
 * 2 of the GPL, you may redistribute this Program in connection
 * with Free/Libre and Open Source Software ("FLOSS") applications
 * as described in the GPL FLOSS exception.  You should have received
 * a copy of the text describing the FLOSS exception along with this
 * distribution.
 */

public class Main {
    private static String byteToCharMap = null;
    private static final char PADDING = '=';

    private static byte charToByte(char encodedChar) {

        byte result = 0;

        // All indexes are less than the size of a byte
        if (encodedChar != PADDING)
            result = (byte) (byteToCharMap.indexOf(encodedChar));

        return result;
    }
}

Related

  1. charToByte(char c)
  2. charToByte(char c)
  3. charToByte(char c)
  4. charToByte(char ch)
  5. charToByte(char ch)
  6. charToByte(char[] chars)
  7. charToByte(char[] tab)
  8. charToByte(char[] values)
  9. charToByte(final char value)