List of usage examples for java.lang String toCharArray
public char[] toCharArray()
From source file:Main.java
private static String formatChannelNumber(String value) { if (null == value || "".equals(value)) { return null; }/*from w w w. j a v a2 s . c o m*/ char delimiter = '_'; for (char c : value.toCharArray()) { String test = String.valueOf(c); if (!test.matches("\\d")) { delimiter = c; } } value = value.replace(delimiter, '.'); return value; }
From source file:$.Encodes.java
/** * Hex?.//w w w . j av a2 s . c o m */ public static byte[] decodeHex(String input) { try { return Hex.decodeHex(input.toCharArray()); } catch (DecoderException e) { throw Exceptions.unchecked(e); } }
From source file:MiscUtils.java
/** * Compares two strings.<p>/*from w w w .jav a 2s.c o m*/ * <p/> * Unlike <function>String.compareTo()</function>, * this method correctly recognizes and handles embedded numbers. * For example, it places "My file 2" before "My file 10".<p> * * @param str1 The first string * @param str2 The second string * @param ignoreCase If true, case will be ignored * @return negative If str1 < str2, 0 if both are the same, * positive if str1 > str2 * @since jEdit 4.3pre5 */ public static int compareStrings(String str1, String str2, boolean ignoreCase) { char[] char1 = str1.toCharArray(); char[] char2 = str2.toCharArray(); int len = Math.min(char1.length, char2.length); for (int i = 0, j = 0; i < len && j < len; i++, j++) { char ch1 = char1[i]; char ch2 = char2[j]; if (Character.isDigit(ch1) && Character.isDigit(ch2) && ch1 != '0' && ch2 != '0') { int _i = i + 1; int _j = j + 1; for (; _i < char1.length; _i++) { if (!Character.isDigit(char1[_i])) { //_i--; break; } } for (; _j < char2.length; _j++) { if (!Character.isDigit(char2[_j])) { //_j--; break; } } int len1 = _i - i; int len2 = _j - j; if (len1 > len2) return 1; else if (len1 < len2) return -1; else { for (int k = 0; k < len1; k++) { ch1 = char1[i + k]; ch2 = char2[j + k]; if (ch1 != ch2) return ch1 - ch2; } } i = _i - 1; j = _j - 1; } else { if (ignoreCase) { ch1 = Character.toLowerCase(ch1); ch2 = Character.toLowerCase(ch2); } if (ch1 != ch2) return ch1 - ch2; } } return char1.length - char2.length; }
From source file:com.apabi.qrcode.utils.EncodeUtils.java
/** * Hex?.//from www . j a va2 s .c om */ public static byte[] hexDecode(final String input) { try { return Hex.decodeHex(input.toCharArray()); } catch (DecoderException e) { throw new IllegalStateException("Hex Decoder exception", e); } }
From source file:com.cangqu.gallery.server.base.utils.EncodeUtils.java
/** * //from www . j a va2s .co m */ public static String convertMD5(String inStr) { char[] a = inStr.toCharArray(); for (int i = 0; i < a.length; i++) { a[i] = (char) (a[i] ^ 't'); } String s = new String(a); return s; }
From source file:cz.zeno.miner.Utils.java
public static byte[] hexStringToByteArray(String s) throws DecoderException { if (s.length() % 2 != 0) s = "0" + s; return Hex.decodeHex(s.toCharArray()); }
From source file:com.photon.phresco.commons.CIPasswordScrambler.java
public static String unmask(String secret) throws PhrescoException { if (StringUtils.isEmpty(secret)) { return StringUtils.EMPTY; }// w w w . ja v a2s . co m try { return new String(Base64.decode(secret.toCharArray()), "UTF-8"); } catch (IOException e) { throw new PhrescoException(e); } }
From source file:net.cloudkit.enterprises.infrastructure.utilities.EncodeHelper.java
/** * Hex?.//from www . ja v a2 s .c o m */ public static byte[] decodeHex(String input) { try { return Hex.decodeHex(input.toCharArray()); } catch (DecoderException e) { throw ExceptionHelper.unchecked(e); } }
From source file:Main.java
public static boolean argEquals(String string, String string2) { if (string.toLowerCase().equals(string2.toLowerCase())) return true; StringBuilder sb = new StringBuilder(); for (char c : string2.toCharArray()) { String h = Character.toString(c); if (h.toUpperCase().equals(h)) { sb.append(h);//from ww w. j a v a2 s . c o m } } if (sb.toString().toLowerCase().equals(string.toLowerCase())) return true; return false; }
From source file:Main.java
/** * Converts a string to his binary equivalent. * * @param text The string that must be converted, cannot be null * @return An array of integers representing the binary equivalent *///from w w w. j av a 2s.com public static int[] getBinarySequence(String text) { if (text == null) { throw new NullPointerException("Given text cannot be null"); } char[] textArray = text.toCharArray(); int[] bitList = new int[textArray.length * UTF8_SIZE]; int bitListPtr = 0; for (char asciiValue : textArray) { for (int bitWise = UTF8_SIZE - 1; bitWise >= 0; bitWise--) { int tempBit = ((asciiValue & (1 << bitWise)) > 0) ? 1 : 0; bitList[bitListPtr] = tempBit; bitListPtr++; } } return bitList; }