Java Hex Calculate toHex(String string)

Here you can find the source of toHex(String string)

Description

to Hex

License

Open Source License

Declaration

public static String toHex(String string) 

Method Source Code

//package com.java2s;
/*//from   w w w .  j  a v  a 2  s.  co  m
 * Copyright (c) 2006-2012 Nuxeo SA (http://nuxeo.com/) and others.
 *
 * 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:
 *     Nuxeo - initial API and implementation
 *
 * $Id: StringUtils.java 28482 2008-01-04 15:33:39Z sfermigier $
 */

public class Main {
    public static String toHex(String string) {
        char[] chars = string.toCharArray();
        StringBuilder buf = new StringBuilder();
        for (char c : chars) {
            buf.append(Integer.toHexString(c).toUpperCase());
        }
        return buf.toString();
    }
}

Related

  1. toHex(String color)
  2. toHex(String in, boolean javaStyle)
  3. toHEX(String ostr)
  4. toHex(String source)
  5. toHex(String str)
  6. toHex(String txt)
  7. toHex(String val)
  8. toHex(StringBuffer buf, long value, int width)
  9. toHex(StringBuilder s, byte b)