List of usage examples for java.lang String toCharArray
public char[] toCharArray()
From source file:Main.java
private static KeyManager[] prepareKeyManager(InputStream bksFile, String password) { try {/*w w w . j a va 2 s. c o m*/ if (bksFile != null && password != null) { KeyStore e = KeyStore.getInstance("BKS"); e.load(bksFile, password.toCharArray()); KeyManagerFactory keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(e, password.toCharArray()); return keyManagerFactory.getKeyManagers(); } return null; } catch (KeyStoreException var4) { var4.printStackTrace(); } catch (NoSuchAlgorithmException var5) { var5.printStackTrace(); } catch (UnrecoverableKeyException var6) { var6.printStackTrace(); } catch (CertificateException var7) { var7.printStackTrace(); } catch (IOException var8) { var8.printStackTrace(); } catch (Exception var9) { var9.printStackTrace(); } return null; }
From source file:Main.java
@VisibleForTesting public static void copyToCharArrayBuffer(String text, CharArrayBuffer buffer) { if (text != null) { char[] data = buffer.data; if (data == null || data.length < text.length()) { buffer.data = text.toCharArray(); } else {/* w w w .j a v a 2s . c om*/ text.getChars(0, text.length(), data, 0); } buffer.sizeCopied = text.length(); } else { buffer.sizeCopied = 0; } }
From source file:com.pushinginertia.commons.net.email.EmailUtils.java
/** * Converts a text message into an HTML message, replacing all newlines with <br> tags and escaping the '<' * and '>' characters;//from ww w .ja va 2 s . c o m * @param s message in text format * @return message in html format */ public static String textToHtml(final String s) { final StringBuilder sb = new StringBuilder(); for (final char c : s.toCharArray()) { switch (c) { case '\n': sb.append("<br/>"); break; case '<': sb.append("<"); break; case '>': sb.append(">"); break; case '&': sb.append("&"); break; default: sb.append(c); } } return sb.toString(); }
From source file:Main.java
/** * create the parser based on the given source code. * //from w w w .j a v a2 s .c om * @param source * the given source code * @return */ public static ASTParser getParser(String source) { ASTParser parser = ASTParser.newParser(AST.JLS3); //parser.setKind(ASTParser.K_STATEMENTS); parser.setProject(getProject()); parser.setSource(source.toCharArray()); //parser.setResolveBindings(true); return parser; }
From source file:com.kotcrab.vis.editor.module.editor.AnalyticsModule.java
public static int truncateUtf8(String input, byte[] output) { ByteBuffer outBuf = ByteBuffer.wrap(output); CharBuffer inBuf = CharBuffer.wrap(input.toCharArray()); Charset utf8 = Charset.forName("UTF-8"); utf8.newEncoder().encode(inBuf, outBuf, true); return outBuf.position(); }
From source file:Main.java
public static String capitalizeFirstChar(String name) { if (name == null || name.length() == 0) { return name; }/* ww w. ja v a 2 s . com*/ if (name.startsWith("_")) { return capitalizeFirstChar(name.substring(1)); } char chars[] = name.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); }
From source file:cc.recommenders.utils.Zips.java
public static ICoReMethodName method(ZipEntry e, String suffix) { String name = "L" + StringUtils.substringBefore(e.getName(), suffix); int start = name.lastIndexOf('/'); char[] chars = name.toCharArray(); chars[start] = '.'; for (int i = start + 1; i < chars.length; i++) { if (chars[i] == '.') chars[i] = '/'; }// w w w .ja v a 2 s .c om return CoReMethodName.get(new String(chars)); }
From source file:com.mastercard.mobile_api.utils.Tlv.java
/** * Creates a Tlv byte array from a tag and a value. Length is calculated. * Data Input is in Hex String/*from ww w .j av a 2 s.c o m*/ * * @param tag the Tlv tag (HEX String) * @param value the Tlv value (HEX String) * @return the Tlv byte array (HEX String) */ public static String create(String tag, String value) { byte[] bValue = new byte[0]; try { bValue = Hex.decodeHex(value.toCharArray()); } catch (DecoderException e) { e.printStackTrace(); } byte[] bLength = lengthBytes(bValue); String length = new String(Hex.encodeHex(bLength)); return (tag + length + value).toUpperCase(); }
From source file:com.sixrr.stockmetrics.utils.LineUtil.java
static int countLines(String text) { int lines = 0; boolean onEmptyLine = true; final char[] chars = text.toCharArray(); for (final char aChar : chars) { if (aChar == '\n' || aChar == '\r') { if (!onEmptyLine) { lines++;//from w w w . j a v a 2 s.c o m onEmptyLine = true; } } else if (aChar == ' ' || aChar == '\t') { //don't do anything } else { onEmptyLine = false; } } if (!onEmptyLine) { lines++; } return lines; }
From source file:de.codesourcery.eve.skills.ui.utils.IntTextFieldValidator.java
protected static boolean isInteger(String s) { if (StringUtils.isBlank(s)) { return false; }/*w ww . j a v a 2 s. c o m*/ for (char c : s.toCharArray()) { if (!Character.isDigit(c) && c != '-') { return false; } } return true; }