Java Hex Calculate toHexString(char c)

Here you can find the source of toHexString(char c)

Description

to Hex String

License

Open Source License

Declaration

private static String toHexString(char c) 

Method Source Code

//package com.java2s;
/*/*from  w w  w.  j av a  2  s. co m*/
 * This file is part of Dorado 7.x (http://dorado7.bsdn.org).
 * 
 * Copyright (c) 2002-2012 BSTEK Corp. All rights reserved.
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * and BSDN commercial (http://www.bsdn.org/licenses) licenses.
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at http://www.bstek.com/contact.
 */

public class Main {
    private static String toHexString(char c) {
        if (c > 127) {
            throw new IllegalArgumentException("Unsupported char [" + c + "].");
        }

        String s = Integer.toHexString(c);
        if (s.length() == 1)
            return '0' + s;
        else
            return s;
    }
}

Related

  1. toHexString(byte[] v)
  2. toHexString(byte[] val)
  3. toHexString(byte[] value)
  4. toHexString(byte[] value)
  5. toHexString(byte[] value, int startOffset, int maxLength, boolean uppercase, char separator)
  6. toHexString(final byte b)
  7. toHexString(final byte b)
  8. toHexString(final byte hex)
  9. toHexString(final byte value)