本文整理了Java中java.lang.String.toCharArray()
方法的一些代码示例,展示了String.toCharArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。String.toCharArray()
方法的具体详情如下:
包路径:java.lang.String
类名称:String
方法名:toCharArray
[英]Converts this string to a new character array.
[中]将此字符串转换为新的字符数组。
代码示例来源:origin: google/guava
/** Returns a new escaper based on the current state of the builder. */
public Escaper build() {
return new ArrayBasedCharEscaper(replacementMap, safeMin, safeMax) {
private final char[] replacementChars =
unsafeReplacement != null ? unsafeReplacement.toCharArray() : null;
@Override
protected char[] escapeUnsafe(char c) {
return replacementChars;
}
};
}
}
代码示例来源:origin: google/guava
private SingleWidth() {
super(
"CharMatcher.singleWidth()",
"\u0000\u05be\u05d0\u05f3\u0600\u0750\u0e00\u1e00\u2100\ufb50\ufe70\uff61".toCharArray(),
"\u04f9\u05be\u05ea\u05f4\u06ff\u077f\u0e7f\u20af\u213a\ufdff\ufeff\uffdc".toCharArray());
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public char[] getChars() {
return ("/{*"+this.variableName+"}").toCharArray();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public char[] getChars() {
return (this.separator+"**").toCharArray();
}
}
代码示例来源:origin: stackoverflow.com
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for ( int j = 0; j < bytes.length; j++ ) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
Object pw = "Password";
System.out.println("String: " + pw);
pw = "Password".toCharArray();
System.out.println("Array: " + pw);
}
代码示例来源:origin: spring-projects/spring-framework
public char[] getChars() {
StringBuilder b = new StringBuilder();
b.append("{");
b.append(this.variableName);
if (this.constraintPattern != null) {
b.append(":").append(this.constraintPattern.pattern());
}
b.append("}");
return b.toString().toCharArray();
}
代码示例来源:origin: google/guava
@Override
protected char[] escapeUnsafe(char c) {
return ("{" + c + "}").toCharArray();
}
};
代码示例来源:origin: google/guava
@Override
protected char[] escapeUnsafe(int c) {
return ("{" + (char) c + "}").toCharArray();
}
};
代码示例来源:origin: google/guava
@Override
protected char[] escapeUnsafe(char c) {
return ("{" + c + "}").toCharArray();
}
};
代码示例来源:origin: spring-projects/spring-framework
public DefaultPathSegment(String value, String valueToMatch, MultiValueMap<String, String> params) {
Assert.isTrue(!value.contains("/"), () -> "Invalid path segment value: " + value);
this.value = value;
this.valueToMatch = valueToMatch;
this.valueToMatchAsChars = valueToMatch.toCharArray();
this.parameters = CollectionUtils.unmodifiableMultiValueMap(params);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public char[] convert(String source) {
return source.toCharArray();
}
});
代码示例来源:origin: google/guava
@Override
protected char[] escape(int cp) {
return ('a' <= cp && cp <= 'z') || ('A' <= cp && cp <= 'Z') || ('0' <= cp && cp <= '9')
? null
: ("[" + String.valueOf(cp) + "]").toCharArray();
}
};
代码示例来源:origin: google/guava
public void testWriteMethods() throws IOException {
StringBuilder builder = new StringBuilder();
Writer writer = new AppendableWriter(builder);
writer.write("Hello".toCharArray());
writer.write(',');
writer.write(0xBEEF0020); // only lower 16 bits are important
writer.write("Wo");
writer.write("Whirled".toCharArray(), 3, 2);
writer.write("Mad! Mad, I say", 2, 2);
assertEquals("Hello, World!", builder.toString());
}
代码示例来源:origin: spring-projects/spring-framework
private void handleComment(Comment comment) throws SAXException {
if (getLexicalHandler() != null) {
char[] ch = comment.getText().toCharArray();
getLexicalHandler().comment(ch, 0, ch.length);
}
}
代码示例来源:origin: google/guava
private static void assertEqualCharNodes(Iterable<Character> result, String expectedCharacters) {
assertThat(ImmutableList.copyOf(result))
.containsExactlyElementsIn(Chars.asList(expectedCharacters.toCharArray()))
.inOrder();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void servletWriterAutoFlushedForCharArray() throws IOException {
response.getWriter().write("XY".toCharArray());
assertEquals("XY", response.getContentAsString());
}
代码示例来源:origin: google/guava
public void testCharsIgnored() {
for (char c : IGNORED.toCharArray()) {
String str = String.valueOf(c);
assertTrue(str, c == Ascii.toLowerCase(c));
assertTrue(str, c == Ascii.toUpperCase(c));
assertFalse(str, Ascii.isLowerCase(c));
assertFalse(str, Ascii.isUpperCase(c));
}
}
代码示例来源:origin: google/guava
public void testCharsLower() {
for (char c : LOWER.toCharArray()) {
String str = String.valueOf(c);
assertTrue(str, c == Ascii.toLowerCase(c));
assertFalse(str, c == Ascii.toUpperCase(c));
assertTrue(str, Ascii.isLowerCase(c));
assertFalse(str, Ascii.isUpperCase(c));
}
}
代码示例来源:origin: google/guava
public void testCharsUpper() {
for (char c : UPPER.toCharArray()) {
String str = String.valueOf(c);
assertFalse(str, c == Ascii.toLowerCase(c));
assertTrue(str, c == Ascii.toUpperCase(c));
assertFalse(str, Ascii.isLowerCase(c));
assertTrue(str, Ascii.isUpperCase(c));
}
}
内容来源于网络,如有侵权,请联系作者删除!