List of usage examples for java.lang String toCharArray
public char[] toCharArray()
From source file:Main.java
public static String encodeUrl(String inputUrl) { if (isBlank(inputUrl)) return inputUrl; char[] charArray = inputUrl.toCharArray(); for (int i = 0; i < charArray.length; i++) { if ((charArray[i] >= 0x4e00) && (charArray[i] <= 0x9fbb)) { inputUrl = inputUrl.replaceFirst(String.valueOf(charArray[i]), URLEncoder.encode(String.valueOf(charArray[i]))); }/* w w w. j av a 2s. c om*/ } return inputUrl; }
From source file:Main.java
public static byte ConvertStringToHexByte(String StringToConvert) { StringToConvert = StringToConvert.toUpperCase(); char[] CharArray = StringToConvert.toCharArray(); char[] Char = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; int result = 0; for (int i = 0; i <= 1; i++) { for (int j = 0; j <= 15; j++) { if (CharArray[i] == Char[j]) { if (i == 1) { result = result + j; j = 15;/*from w ww. ja v a 2 s . c o m*/ } else if (i == 0) { result = result + j * 16; j = 15; } } } } return (byte) result; }
From source file:Main.java
private static SecretKey getKeyFromPassphrase(String passphrase, byte[] salt) throws GeneralSecurityException { PBEKeySpec keyspec = new PBEKeySpec(passphrase.toCharArray(), salt, 100); SecretKeyFactory skf = SecretKeyFactory.getInstance("PBEWITHSHA1AND128BITAES-CBC-BC"); return skf.generateSecret(keyspec); }
From source file:de.rnd7.kata.reversi.logic.ai.AIMatrix.java
private static void processLine(final AIMatrix matrix, final int y, final String line) { int x = 0;/*from ww w . j av a 2s . c om*/ for (final char ch : line.toCharArray()) { final int weight; if (Character.isLowerCase(ch)) { weight = -Character.toUpperCase(ch); } else { weight = ch; } matrix.set(new Coordinate(x++, y), weight); } }
From source file:net.sourceforge.fenixedu.domain.degreeStructure.EctsComparabilityTable.java
public static EctsComparabilityTable fromString(String serialized) { return new EctsComparabilityTable(serialized.toCharArray()); }
From source file:Main.java
public static String xmlSpecialChar(String value) { StringBuilder sb = new StringBuilder(value.length()); char[] chars = value.toCharArray(); for (char c : chars) { switch (c) { case '<': sb.append("<"); break; case '>': sb.append(">"); break; case '&': sb.append("&"); break; case '\'': sb.append("'"); break; case '"': sb.append("""); break; default:/* ww w .j a va 2s . c o m*/ sb.append(c); break; } } return sb.toString(); }
From source file:Main.java
public static boolean checkCN(String str) { if (str == null || str.length() == 0) { return false; }//from ww w . j a va 2 s. c o m char[] cArray = str.toCharArray(); for (int i = 0; i < cArray.length; i++) { for (int j = 0; j < INVALID_CH_CN.length; j++) { if (cArray[i] == INVALID_CH_CN[j]) { return false; } } } return true; }
From source file:NumericCharacterReference.java
/** * Encode a String with Numeric Character Refernces. * <p>// ww w. ja va2 s.co m * Formats each character < 0x20 or > 0x7f to &#nnnn; where nnnn is the char value as int. * <p> * * @param str The raw String * @return The encoded String */ public static String encode(String str) { char[] ch = str.toCharArray(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < ch.length; i++) { if (ch[i] < 0x20 || ch[i] > 0x7f) sb.append("&#").append((int) ch[i]).append(";"); else sb.append(ch[i]); } return sb.toString(); }
From source file:io.spring.initializr.util.VersionProperty.java
private static String validateFormat(String property) { for (char c : property.toCharArray()) { if (Character.isUpperCase(c)) { throw new IllegalArgumentException( "Invalid property '" + property + "', must not contain upper case"); }/*from w ww.ja v a 2 s .c o m*/ if (!Character.isLetterOrDigit(c) && !SUPPORTED_CHARS.contains(c)) { throw new IllegalArgumentException("Unsupported character '" + c + "' for '" + property + "'"); } } return property; }
From source file:edu.mayo.cts2.framework.plugin.service.lexevs.uri.UriUtils.java
private static int getSeparatorPosition(String string) { char[] chars = string.toCharArray(); for (int i = chars.length - 1; i > 0; i--) { if (SEPARATORS.contains(chars[i])) { return i; }/*from w ww . ja v a 2 s. c o m*/ } throw new BadUriException("Malformed URI: " + string); }