java.lang.StringBuilder.getChars()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中java.lang.StringBuilder.getChars()方法的一些代码示例,展示了StringBuilder.getChars()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuilder.getChars()方法的具体详情如下:
包路径:java.lang.StringBuilder
类名称:StringBuilder
方法名:getChars

StringBuilder.getChars介绍

暂无

代码示例

代码示例来源:origin: groovy/groovy-core

private static char[] getCharsFromStringBuilder(StringBuilder sbuf) {
  final int length = sbuf.length();
  char[] array2 = new char[length];
  sbuf.getChars(0, length, array2, 0);
  return array2;
}

代码示例来源:origin: jfinal/jfinal

public Lexer(StringBuilder content, String fileName) {
  int len = content.length();
  buf = new char[len + 1];
  content.getChars(0, content.length(), buf, 0);
  buf[len] = EOF;
  this.fileName = fileName;
}

代码示例来源:origin: neo4j/neo4j

/**
   * Reads characters into an array.
   *
   * @param pos The position of this file to start reading from
   * @param cbuf Destination buffer
   * @param off Offset at which to start storing characters
   * @param len Maximum number of characters to read (> 0)
   * @return The number of characters read (0 if no characters remain)
   * @see java.io.Reader#read(char[], int, int)
   */
  public int read( int pos, char[] cbuf, int off, int len )
  {
    len = Math.min( content.length() - pos, len );
    content.getChars( pos, pos + len, cbuf, off );
    return len;
  }
}

代码示例来源:origin: hankcs/HanLP

public char[] generateParameter(Table table, int current)
{
  StringBuilder sb = new StringBuilder();
  int i = 0;
  for (String d : delimiterList)
  {
    sb.append(d);
    int[] offset = offsetList.get(i++);
    sb.append(table.get(current + offset[0], offset[1]));
  }
  char[] o = new char[sb.length()];
  sb.getChars(0, sb.length(), o, 0);
  return o;
}

代码示例来源:origin: robovm/robovm

/**
 * Creates a {@code String} from the contents of the specified {@code
 * StringBuilder}.
 *
 * @throws NullPointerException
 *             if {@code stringBuilder == null}.
 * @since 1.5
 */
public String(StringBuilder stringBuilder) {
  if (stringBuilder == null) {
    throw new NullPointerException("stringBuilder == null");
  }
  this.offset = 0;
  this.count = stringBuilder.length();
  this.value = new char[this.count];
  stringBuilder.getChars(0, this.count, this.value, 0);
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

protected char[] getEscapeChars( boolean includeSingleQuote, boolean includeDoubleQuote )
{
  StringBuilder buf = new StringBuilder( 2 );
  if ( includeSingleQuote )
  {
    buf.append( '\'' );
  }
  if ( includeDoubleQuote )
  {
    buf.append( '\"' );
  }
  char[] result = new char[buf.length()];
  buf.getChars( 0, buf.length(), result, 0 );
  return result;
}

代码示例来源:origin: jfinal/jfinal

public void write(StringBuilder stringBuilder, int offset, int len) throws IOException {
  while (len > chars.length) {
    write(stringBuilder, offset, chars.length);
    offset += chars.length;
    len -= chars.length;
  }
  
  stringBuilder.getChars(offset, offset + len, chars, 0);
  out.write(chars, 0, len);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Encode the given {@link Password} to a char array.
 *
 * @param password the password to encode
 * @return a char array representing the encoded password
 * @throws InvalidKeySpecException if the given password is not supported or could be encoded
 */
public static char[] encode(Password password) throws InvalidKeySpecException {
  StringBuilder b = getCryptStringToBuilder(password);
  char[] chars = new char[b.length()];
  b.getChars(0, b.length(), chars, 0);
  return chars;
}

代码示例来源:origin: jfinal/jfinal

public char[] getChars() {
  if (chars != null) {
    return chars;
  }
  
  synchronized (this) {
    if (chars != null) {
      return chars;
    }
    
    if (content != null) {
      char[] charsTemp = new char[content.length()];
      content.getChars(0, content.length(), charsTemp, 0);
      chars = charsTemp;
      content = null;
      return chars;
    } else {
      String strTemp = new String(bytes, charset);
      char[] charsTemp = new char[strTemp.length()];
      strTemp.getChars(0, strTemp.length(), charsTemp, 0);
      chars = charsTemp;
      return chars;
    }
  }
}

代码示例来源:origin: jfinal/jfinal

public void write(StringBuilder stringBuilder, int offset, int len) throws IOException {
  while (len > chars.length) {
    write(stringBuilder, offset, chars.length);
    offset += chars.length;
    len -= chars.length;
  }
  
  stringBuilder.getChars(offset, offset + len, chars, 0);
  int byteLen = encoder.encode(chars, 0, len, bytes);
  out.write(bytes, 0, byteLen);
}

代码示例来源:origin: jfinal/jfinal

public ExprLexer(ParaToken paraToken, Location location) {
  this.location = location;
  StringBuilder content = paraToken.getContent();
  beginRow = paraToken.getRow();
  forwardRow = beginRow;
  if (content == null) {
    buf = new char[]{EOF};
    return ;
  }
  int len = content.length();
  buf = new char[len + 1];
  content.getChars(0, content.length(), buf, 0);
  buf[len] = EOF;
}

代码示例来源:origin: redisson/redisson

p.getChars(p.length() - 3, p.length(), data, 0);
return f.append(data).toString();

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public final CharTermAttribute append(StringBuilder s) {
 if (s == null) // needed for Appendable compliance
  return appendNull();
 final int len = s.length();
 s.getChars(0, len, resizeBuffer(termLength + len), termLength);
 termLength += len;
 return this;
}

代码示例来源:origin: looly/hutool

((String) csq).getChars(0, len, this.value, index);
} else if (csq instanceof StringBuilder) {
  ((StringBuilder) csq).getChars(0, len, this.value, index);
} else if (csq instanceof StringBuffer) {
  ((StringBuffer) csq).getChars(0, len, this.value, index);

代码示例来源:origin: looly/hutool

((String) csq).getChars(0, len, this.value, index);
} else if (csq instanceof StringBuilder) {
  ((StringBuilder) csq).getChars(0, len, this.value, index);
} else if (csq instanceof StringBuffer) {
  ((StringBuffer) csq).getChars(0, len, this.value, index);

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Appends a StringBuilder to this string builder.
 * Appending null will call {@link #appendNull()}.
 *
 * @param str the StringBuilder to append
 * @return this, to enable chaining
 * @since 3.2
 */
public StrBuilder append(final StringBuilder str) {
  if (str == null) {
    return appendNull();
  }
  final int strLen = str.length();
  if (strLen > 0) {
    final int len = length();
    ensureCapacity(len + strLen);
    str.getChars(0, strLen, buffer, len);
    size += strLen;
  }
  return this;
}

代码示例来源:origin: org.pegdown/pegdown

public RootNode parseInternal(StringBuilderVar block) {
  char[] chars = block.getChars();
  int[] ixMap = new int[chars.length + 1]; // map of cleaned indices to original indices
  
  // strip out CROSSED_OUT characters and build index map
  StringBuilder clean = new StringBuilder();
  for (int i = 0; i < chars.length; i++) {
    char c = chars[i];
    if (c != CROSSED_OUT) {
      ixMap[clean.length()] = i;
      clean.append(c);
    }
  }
  ixMap[clean.length()] = chars.length;
  
  // run inner parse
  char[] cleaned = new char[clean.length()];
  clean.getChars(0, cleaned.length, cleaned, 0);
  RootNode rootNode = parseInternal(cleaned);
  
  // correct AST indices with index map
  fixIndices(rootNode, ixMap);
  
  return rootNode;
}

代码示例来源:origin: jphp-group/jphp

_pad = ' ';
prefix.getChars(0, _prefix.length, _prefix, 0);

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Appends part of a StringBuilder to this string builder.
 * Appending null will call {@link #appendNull()}.
 *
 * @param str the StringBuilder to append
 * @param startIndex the start index, inclusive, must be valid
 * @param length the length to append, must be valid
 * @return this, to enable chaining
 * @since 3.2
 */
public StrBuilder append(final StringBuilder str, final int startIndex, final int length) {
  if (str == null) {
    return appendNull();
  }
  if (startIndex < 0 || startIndex > str.length()) {
    throw new StringIndexOutOfBoundsException("startIndex must be valid");
  }
  if (length < 0 || (startIndex + length) > str.length()) {
    throw new StringIndexOutOfBoundsException("length must be valid");
  }
  if (length > 0) {
    final int len = length();
    ensureCapacity(len + length);
    str.getChars(startIndex, startIndex + length, buffer, len);
    size += length;
  }
  return this;
}

代码示例来源:origin: org.apache.lucene/lucene-core

((String) csq).getChars(start, end, termBuffer, termLength);
} else if (csq instanceof StringBuilder) {
 ((StringBuilder) csq).getChars(start, end, termBuffer, termLength);
} else if (csq instanceof CharTermAttribute) {
 System.arraycopy(((CharTermAttribute) csq).buffer(), start, termBuffer, termLength, len);

相关文章

微信公众号

最新文章

更多