Tabnine Logo
StringBuilder.replace
Code IndexAdd Tabnine to your IDE (free)

How to use
replace
method
in
java.lang.StringBuilder

Best Java code snippets using java.lang.StringBuilder.replace (Showing top 20 results out of 8,559)

origin: google/j2objc

  private static String join(StringBuilder out, Object[] linesToBreak) {
    for (Object line : linesToBreak) {
      out.append(line.toString()).append("\n");
    }
    int lastBreak = out.lastIndexOf("\n");
    return out.replace(lastBreak, lastBreak+1, "").toString();
  }
}
origin: google/error-prone

private static String replaceLast(String text, String pattern, String replacement) {
 StringBuilder builder = new StringBuilder(text);
 int lastIndexOf = builder.lastIndexOf(pattern);
 return builder.replace(lastIndexOf, lastIndexOf + pattern.length(), replacement).toString();
}
origin: google/error-prone

 private String replaceLast(String text, String pattern, String replacement) {
  StringBuilder builder = new StringBuilder(text);
  int lastIndexOf = builder.lastIndexOf(pattern);
  return builder.replace(lastIndexOf, lastIndexOf + pattern.length(), replacement).toString();
 }
},
origin: google/error-prone

/** Replace the source code with the new lines of code. */
public void replaceLines(List<String> lines) {
 sourceBuilder.replace(0, sourceBuilder.length(), Joiner.on("\n").join(lines) + "\n");
}
origin: bumptech/glide

@Override
public String toString() {
 StringBuilder sb =
   new StringBuilder()
     .append("SizeConfigStrategy{groupedMap=")
     .append(groupedMap)
     .append(", sortedSizes=(");
 for (Map.Entry<Bitmap.Config, NavigableMap<Integer, Integer>> entry : sortedSizes.entrySet()) {
  sb.append(entry.getKey()).append('[').append(entry.getValue()).append("], ");
 }
 if (!sortedSizes.isEmpty()) {
  sb.replace(sb.length() - 2, sb.length(), "");
 }
 return sb.append(")}").toString();
}
origin: hibernate/hibernate-orm

protected String format(int intValue) {
  String formatted = Integer.toHexString( intValue );
  StringBuilder buf = new StringBuilder( "00000000" );
  buf.replace( 8 - formatted.length(), 8, formatted );
  return buf.toString();
}
origin: hibernate/hibernate-orm

  protected String format(short shortValue) {
    String formatted = Integer.toHexString( shortValue );
    StringBuilder buf = new StringBuilder( "0000" );
    buf.replace( 4 - formatted.length(), 4, formatted );
    return buf.toString();
  }
}
origin: hibernate/hibernate-orm

public static String format(short value) {
  String formatted = Integer.toHexString( value );
  StringBuilder buf = new StringBuilder( "0000" );
  buf.replace( 4 - formatted.length(), 4, formatted );
  return buf.toString();
}
origin: hibernate/hibernate-orm

public static String format(int value) {
  final String formatted = Integer.toHexString( value );
  StringBuilder buf = new StringBuilder( "00000000" );
  buf.replace( 8 - formatted.length(), 8, formatted );
  return buf.toString();
}
origin: stanfordnlp/CoreNLP

@Override
public String toString() {
 StringBuilder b = new StringBuilder();
 b.append(cl.getName()).append('(');
 for (Class<?> cl : classParams) {
  b.append(' ').append(cl.getName()).append(',');
 }
 b.replace(b.length() - 1, b.length(), " ");
 b.append(')');
 return b.toString();
}
origin: pockethub/PocketHub

private static boolean replace(final StringBuilder input,
                final String from, final String to) {
  int start = input.indexOf(from);
  if (start == -1) {
    return false;
  }
  final int fromLength = from.length();
  final int toLength = to.length();
  while (start != -1) {
    input.replace(start, start + fromLength, to);
    start = input.indexOf(from, start + toLength);
  }
  return true;
}
origin: stackoverflow.com

 public static void replaceAll(StringBuilder builder, String from, String to)
{
  int index = builder.indexOf(from);
  while (index != -1)
  {
    builder.replace(index, index + from.length(), to);
    index += to.length(); // Move to the end of the replacement
    index = builder.indexOf(from, index);
  }
}
origin: bumptech/glide

 @Override
 public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("( ");
  for (Entry<K, V> entry : entrySet()) {
   sb.append('{').append(entry.getKey()).append(':').append(entry.getValue()).append("}, ");
  }
  if (!isEmpty()) {
   sb.replace(sb.length() - 2, sb.length(), "");
  }
  return sb.append(" )").toString();
 }
}
origin: hibernate/hibernate-orm

public static String toBinaryString(byte value) {
  String formatted = Integer.toBinaryString( value );
  if ( formatted.length() > 8 ) {
    formatted = formatted.substring( formatted.length() - 8 );
  }
  StringBuilder buf = new StringBuilder( "00000000" );
  buf.replace( 8 - formatted.length(), 8, formatted );
  return buf.toString();
}
origin: aws/aws-sdk-java

public static String replace( String originalString, String partToMatch, String replacement ) {
  StringBuilder buffer = new StringBuilder( originalString.length() );
  buffer.append( originalString );
  int indexOf = buffer.indexOf( partToMatch );
  while (indexOf != -1) {
    buffer = buffer.replace(indexOf, indexOf + partToMatch.length(), replacement);
    indexOf = buffer.indexOf(partToMatch, indexOf + replacement.length());
  }
  return buffer.toString();
}
origin: square/picasso

static void updateThreadName(Request data) {
 String name = data.getName();
 StringBuilder builder = NAME_BUILDER.get();
 builder.ensureCapacity(Utils.THREAD_PREFIX.length() + name.length());
 builder.replace(Utils.THREAD_PREFIX.length(), builder.length(), name);
 Thread.currentThread().setName(builder.toString());
}
origin: hibernate/hibernate-orm

  @AllowSysOut
  public static void main(String[] args) throws UnknownHostException {
    byte[] addressBytes = InetAddress.getLocalHost().getAddress();
    System.out.println( "Raw ip address bytes : " + addressBytes.toString() );

    int addressInt = BytesHelper.toInt( addressBytes );
    System.out.println( "ip address int : " + addressInt );

    String formatted = Integer.toHexString( addressInt );
    StringBuilder buf = new StringBuilder( "00000000" );
    buf.replace( 8 - formatted.length(), 8, formatted );
    String addressHex = buf.toString();
    System.out.println( "ip address hex : " + addressHex );
  }
}
origin: hibernate/hibernate-orm

  public static String toBinaryString(long value) {
    String formatted = Long.toBinaryString( value );
    StringBuilder buf = new StringBuilder( StringHelper.repeat( '0', 64 ) );
    buf.replace( 64 - formatted.length(), 64, formatted );
    return buf.toString();
  }
}
origin: hibernate/hibernate-orm

public static String toBinaryString(int value) {
  String formatted = Long.toBinaryString( value );
  StringBuilder buf = new StringBuilder( StringHelper.repeat( '0', 32 ) );
  buf.replace( 64 - formatted.length(), 64, formatted );
  return buf.toString();
}
origin: square/wire

@Override
public String toString() {
 StringBuilder builder = new StringBuilder();
 if (deprecated != null) builder.append(", deprecated=").append(deprecated);
 if (idempotency_level != null) builder.append(", idempotency_level=").append(idempotency_level);
 if (!uninterpreted_option.isEmpty()) builder.append(", uninterpreted_option=").append(uninterpreted_option);
 return builder.replace(0, 2, "MethodOptions{").append('}').toString();
}
java.langStringBuilderreplace

Javadoc

Replaces the specified subsequence in this builder with the specified string.

Popular methods of StringBuilder

  • append
  • toString
  • <init>
    Constructs a string builder initialized to the contents of the specified string. The initial capacit
  • length
  • setLength
  • charAt
  • deleteCharAt
  • insert
  • substring
  • delete
  • setCharAt
  • indexOf
  • setCharAt,
  • indexOf,
  • lastIndexOf,
  • reverse,
  • appendCodePoint,
  • getChars,
  • subSequence,
  • ensureCapacity,
  • trimToSize

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • getSupportFragmentManager (FragmentActivity)
  • notifyDataSetChanged (ArrayAdapter)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Reference (javax.naming)
  • Table (org.hibernate.mapping)
    A relational table
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now