List of usage examples for java.lang String toCharArray
public char[] toCharArray()
From source file:com.ddubyat.develop.jhawtcode.web.InternalResourceController.java
private static boolean isNumeric(String str) { for (char c : str.toCharArray()) { if (!Character.isDigit(c)) return false; }//from ww w .j av a2s .c om return true; }
From source file:com.jfrog.bintray.client.impl.util.URIUtil.java
/** * Unescape and decode a given string regarded as an escaped string. * * @param escaped a string//from w ww .j a v a 2s . c o m * @param charset the charset * @return the unescaped string * @throws HttpException if the charset is not supported */ public static String decode(String escaped, String charset) throws HttpException { return URI.decode(escaped.toCharArray(), charset); }
From source file:energy.usef.environment.tool.security.KeystoreService.java
private static char[] toCharArray(String value) { return value == null ? new char[0] : value.toCharArray(); }
From source file:jef.testbase.JefTester.java
private static void sampleAdd(Map<Integer, Integer> data, BufferedReader r) throws IOException { String line; while ((line = r.readLine()) != null) { for (char c : line.toCharArray()) { total++;/* w w w . j a v a2 s . com*/ Integer i = (int) c; if (!CharUtils.isAscii((char) i.intValue())) { totalStat++; if (data.containsKey(i)) { data.put(i, data.get(i) + 1); } else { data.put(i, 1); } } } } }
From source file:Main.java
public static int getLength(String value) { try {/*w ww.ja v a2 s . co m*/ int ret = 0; if (value == null) return ret; char[] chars = value.toCharArray(); for (int i = 0; i < chars.length; i++) { String target = String.valueOf(chars[i]); byte[] b = target.getBytes(); if (b.length == 2) { ret += 2; } else { ret++; } } return ret; } catch (Exception e) { return -1; } }
From source file:com.liferay.petra.mail.InternetAddressUtil.java
public static void validateAddress(Address address) throws AddressException { if (address == null) { throw new AddressException("Email address is null"); }/*www. java2 s. c o m*/ String addressString = address.toString(); for (char c : addressString.toCharArray()) { if ((c == CharPool.NEW_LINE) || (c == CharPool.RETURN)) { StringBundler sb = new StringBundler(3); sb.append("Email address "); sb.append(addressString); sb.append(" is invalid because it contains line breaks"); throw new AddressException(sb.toString()); } } }
From source file:Main.java
/** * Finds the earliest point in string1 at which the first part of string2 matches. For example, * overlapPoint("abcd", "cdef") == 2.//w ww . j a va 2s. c o m */ @VisibleForTesting public static int overlapPoint(String string1, String string2) { if (string1 == null || string2 == null) { return -1; } return overlapPoint(string1.toCharArray(), string2.toCharArray()); }
From source file:com.lhings.java.utils.ByteMan.java
public static byte[] hexStringToByteArray(String str) { byte[] byteArray; try {//from ww w . j a v a2 s . c om byteArray = Hex.decodeHex(str.toCharArray()); } catch (DecoderException e) { byteArray = null; } return byteArray; }
From source file:com.ms.commons.test.math.expression.util.MathExpressionParseUtil.java
private static boolean hasSeparators(String expr) { char[] cs = expr.toCharArray(); int fromIndex = 0; int endIndex = expr.length() - 1; for (int i = fromIndex; i <= endIndex; i++) { char c = cs[i]; switch (c) { case '(': case ')': case '+': case '-': case '*': case '/': return true; }//from w w w. j a v a 2 s .co m } return false; }
From source file:com.baifendian.swordfish.execserver.parameter.placeholder.CalculateUtil.java
/** * ?? P S/* w w w .j a v a 2s. co m*/ * * @param expression "-2+-1*(+3)-(-1) S2+S1*(P3)-(S1)" * @return */ private static String transform(String expression) { char[] arr = expression.toCharArray(); for (int i = 0; i < arr.length; i++) { if (arr[i] == '-') { if (i == 0) { arr[i] = 'S'; } else { char c = arr[i - 1]; if (c == '+' || c == '-' || c == '*' || c == '/' || c == '(') { arr[i] = 'S'; } } } else if (arr[i] == '+') { if (i == 0) { arr[i] = 'P'; } else { char c = arr[i - 1]; if (c == '+' || c == '-' || c == '*' || c == '/' || c == '(') { arr[i] = 'P'; } } } } return new String(arr); }