本文整理了Java中java.lang.Character.isWhitespace()
方法的一些代码示例,展示了Character.isWhitespace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Character.isWhitespace()
方法的具体详情如下:
包路径:java.lang.Character
类名称:Character
方法名:isWhitespace
[英]See #isWhitespace(int).
[中]请参阅#isWhitespace(int)。
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine whether a parameter name ends at the current position,
* that is, whether the given character qualifies as a separator.
*/
private static boolean isParameterSeparator(char c) {
return (c < 128 && separatorIndex[c]) || Character.isWhitespace(c);
}
代码示例来源:origin: neo4j/neo4j
@Override
public TextValue trim()
{
if ( Character.isWhitespace( value ) )
{
return StringValue.EMPTY;
}
else
{
return this;
}
}
代码示例来源:origin: spring-projects/spring-framework
private static boolean containsText(CharSequence str) {
int strLen = str.length();
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(str.charAt(i))) {
return true;
}
}
return false;
}
代码示例来源:origin: Blankj/AndroidUtilCode
private static boolean isSpace(final String s) {
if (s == null) return true;
for (int i = 0, len = s.length(); i < len; ++i) {
if (!Character.isWhitespace(s.charAt(i))) {
return false;
}
}
return true;
}
}
代码示例来源:origin: hankcs/HanLP
private static void loadSpace() {
for (int i = Character.MIN_CODE_POINT; i <= Character.MAX_CODE_POINT; i++) {
if (Character.isWhitespace(i) || Character.isSpaceChar(i)) {
CONVERT[i] = ' ';
}
}
}
代码示例来源:origin: neo4j/neo4j
private static int findSpaceBefore( String description, int position )
{
while ( !Character.isWhitespace( description.charAt( position ) ) )
{
position--;
}
return position + 1;
}
代码示例来源:origin: netty/netty
/**
* Find the index of the first non-white space character in {@code s} starting at {@code offset}.
*
* @param seq The string to search.
* @param offset The offset to start searching at.
* @return the index of the first non-white space character or <{@code 0} if none was found.
*/
public static int indexOfNonWhiteSpace(CharSequence seq, int offset) {
for (; offset < seq.length(); ++offset) {
if (!Character.isWhitespace(seq.charAt(offset))) {
return offset;
}
}
return -1;
}
代码示例来源:origin: prestodb/presto
private static int findLastBlank(String buffer)
{
for (int i = buffer.length() - 1; i >= 0; i--) {
if (Character.isWhitespace(buffer.charAt(i))) {
return i;
}
}
return -1;
}
代码示例来源:origin: perwendel/spark
public static boolean isBlank(final CharSequence cs) {
int strLen;
if (cs == null || (strLen = cs.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (Character.isWhitespace(cs.charAt(i)) == false) {
return false;
}
}
return true;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Trim leading and trailing whitespace from the given {@code String}.
* @param str the {@code String} to check
* @return the trimmed {@code String}
* @see java.lang.Character#isWhitespace
*/
public static String trimWhitespace(String str) {
if (!hasLength(str)) {
return str;
}
int beginIndex = 0;
int endIndex = str.length() - 1;
while (beginIndex <= endIndex && Character.isWhitespace(str.charAt(beginIndex))) {
beginIndex++;
}
while (endIndex > beginIndex && Character.isWhitespace(str.charAt(endIndex))) {
endIndex--;
}
return str.substring(beginIndex, endIndex + 1);
}
代码示例来源:origin: apache/rocketmq
private static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(str.charAt(i))) {
return false;
}
}
return true;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Trim leading whitespace from the given {@code String}.
* @param str the {@code String} to check
* @return the trimmed {@code String}
* @see java.lang.Character#isWhitespace
*/
public static String trimLeadingWhitespace(String str) {
if (!hasLength(str)) {
return str;
}
StringBuilder sb = new StringBuilder(str);
while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {
sb.deleteCharAt(0);
}
return sb.toString();
}
代码示例来源:origin: apache/rocketmq
public static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(str.charAt(i))) {
return false;
}
}
return true;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Trim trailing whitespace from the given {@code String}.
* @param str the {@code String} to check
* @return the trimmed {@code String}
* @see java.lang.Character#isWhitespace
*/
public static String trimTrailingWhitespace(String str) {
if (!hasLength(str)) {
return str;
}
StringBuilder sb = new StringBuilder(str);
while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) {
sb.deleteCharAt(sb.length() - 1);
}
return sb.toString();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Check whether the given {@code CharSequence} contains any whitespace characters.
* @param str the {@code CharSequence} to check (may be {@code null})
* @return {@code true} if the {@code CharSequence} is not empty and
* contains at least 1 whitespace character
* @see Character#isWhitespace
*/
public static boolean containsWhitespace(@Nullable CharSequence str) {
if (!hasLength(str)) {
return false;
}
int strLen = str.length();
for (int i = 0; i < strLen; i++) {
if (Character.isWhitespace(str.charAt(i))) {
return true;
}
}
return false;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Trim <i>all</i> whitespace from the given {@code String}:
* leading, trailing, and in between characters.
* @param str the {@code String} to check
* @return the trimmed {@code String}
* @see java.lang.Character#isWhitespace
*/
public static String trimAllWhitespace(String str) {
if (!hasLength(str)) {
return str;
}
int len = str.length();
StringBuilder sb = new StringBuilder(str.length());
for (int i = 0; i < len; i++) {
char c = str.charAt(i);
if (!Character.isWhitespace(c)) {
sb.append(c);
}
}
return sb.toString();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void parse(String content, SortedSet<ContentChunkInfo> result) {
int position = 0;
while (true) {
position = content.indexOf(getKeyword(), position);
if (position == -1) {
return;
}
position += getKeyword().length();
while (Character.isWhitespace(content.charAt(position))) {
position++;
}
if (content.charAt(position) == '\'') {
position = extractLink(position, '\'', content, result);
}
else if (content.charAt(position) == '"') {
position = extractLink(position, '"', content, result);
}
else {
position = extractUnquotedLink(position, content, result);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void parse(String content, SortedSet<ContentChunkInfo> result) {
int position = 0;
while (true) {
position = content.indexOf(getKeyword(), position);
if (position == -1) {
return;
}
position += getKeyword().length();
while (Character.isWhitespace(content.charAt(position))) {
position++;
}
if (content.charAt(position) == '\'') {
position = extractLink(position, "'", content, result);
}
else if (content.charAt(position) == '"') {
position = extractLink(position, "\"", content, result);
}
else {
position = extractLink(position, content, result);
}
}
}
代码示例来源:origin: square/okhttp
/**
* Returns true if the body in question probably contains human readable text. Uses a small sample
* of code points to detect unicode control characters commonly used in binary file signatures.
*/
static boolean isPlaintext(Buffer buffer) {
try {
Buffer prefix = new Buffer();
long byteCount = buffer.size() < 64 ? buffer.size() : 64;
buffer.copyTo(prefix, 0, byteCount);
for (int i = 0; i < 16; i++) {
if (prefix.exhausted()) {
break;
}
int codePoint = prefix.readUtf8CodePoint();
if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) {
return false;
}
}
return true;
} catch (EOFException e) {
return false; // Truncated UTF-8 sequence.
}
}
代码示例来源:origin: libgdx/libgdx
public static int getWrapIndex (Array<Glyph> glyphs, int start) {
int i = start - 1;
for (; i >= 1; i--) {
int startChar = glyphs.get(i).id;
if (!SimplifiedChinese.legalAtStart(startChar)) continue;
int endChar = glyphs.get(i - 1).id;
if (!SimplifiedChinese.legalAtEnd(endChar)) continue;
// Don't wrap between ASCII chars.
if (startChar < 127 && endChar < 127 && !Character.isWhitespace(startChar)) continue;
return i;
}
return start;
}
内容来源于网络,如有侵权,请联系作者删除!