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

How to use
lastIndexOf
method
in
java.lang.StringBuilder

Best Java code snippets using java.lang.StringBuilder.lastIndexOf (Showing top 20 results out of 4,536)

origin: robolectric/robolectric

private int find_extension()
{
  int lastSlashIndex;

  final StringBuilder str = mString;
  // only look at the filename
  lastSlashIndex = str.lastIndexOf(File.pathSeparator);
  if (lastSlashIndex == -1) {
   lastSlashIndex = 0;
  } else {
   lastSlashIndex++;
  }
  // find the last dot
  return str.lastIndexOf(".", lastSlashIndex);
}

origin: spring-projects/spring-framework

private static void appendSeparatorToScriptIfNecessary(StringBuilder scriptBuilder, @Nullable String separator) {
  if (separator == null) {
    return;
  }
  String trimmed = separator.trim();
  if (trimmed.length() == separator.length()) {
    return;
  }
  // separator ends in whitespace, so we might want to see if the script is trying
  // to end the same way
  if (scriptBuilder.lastIndexOf(trimmed) == scriptBuilder.length() - trimmed.length()) {
    scriptBuilder.append(separator.substring(trimmed.length()));
  }
}
origin: lets-blade/blade

private static StringBuilder clearLastComma(StringBuilder buff) {
  int lastComma = buff.lastIndexOf(", ");
  // No comma found, take everything
  if (-1 != lastComma)
    buff.delete(lastComma, buff.length());
  return buff;
}
origin: lets-blade/blade

private static StringBuilder clearLastComma(StringBuilder buff) {
  int lastComma = buff.lastIndexOf(", ");
  // No comma found, take everything
  if (-1 != lastComma)
    buff.delete(lastComma, buff.length());
  return buff;
}
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: geoserver/geoserver

  static void replaceVariable(StringBuilder sb, String key, String value) {
    // infinite loop avoidance
    if (key.equals(value)) {
      return;
    }

    // replace with minimum char movement
    int idx = sb.lastIndexOf(key);
    while (idx >= 0) {
      sb.replace(idx, idx + key.length(), value);
      idx = sb.lastIndexOf(key, idx);
    }
  }
}
origin: networknt/light-4j

private void removeLastSegment(StringBuilder b) {
  int index = b.lastIndexOf("/");
  if (index == -1) {
    b.setLength(0);
  } else {
    b.setLength(index);
  }
}
origin: AdoptOpenJDK/jitwatch

public static String wordWrap(String text, int width)
{
  StringBuilder builder = new StringBuilder(text);
  int i = 0;
  while (i + width < builder.length() && (i = builder.lastIndexOf(S_SPACE, i + width)) != -1)
  {
    builder.replace(i, i + 1, S_NEWLINE);
  }
  return builder.toString();
}
origin: AdoptOpenJDK/jitwatch

public static String wordWrap(String text, int width)
{
  StringBuilder builder = new StringBuilder(text);
  int i = 0;
  while (i + width < builder.length() && (i = builder.lastIndexOf(S_SPACE, i + width)) != -1)
  {
    builder.replace(i, i + 1, S_NEWLINE);
  }
  return builder.toString();
}
origin: apache/nifi

public static String join(final Collection collection, String delimiter) {
  if (collection == null || collection.size() == 0) {
    return EMPTY;
  }
  final StringBuilder sb = new StringBuilder(collection.size() * 16);
  for (Object element : collection) {
    sb.append((String) element);
    sb.append(delimiter);
  }
  return sb.toString().substring(0, sb.lastIndexOf(delimiter));
}
origin: robovm/robovm

  private String substituteNameFromMap(String name, Map<String, String> keywordMap) {
    StringBuilder sbName = new StringBuilder(name);
    int fromIndex = sbName.length();
    int equalIndex;
    while (-1 != (equalIndex = sbName.lastIndexOf("=", fromIndex))) {
      int commaIndex = sbName.lastIndexOf(",", equalIndex);
      String subName = sbName.substring(commaIndex + 1, equalIndex).trim();
      if (keywordMap.containsKey(subName)) {
        sbName.replace(commaIndex + 1, equalIndex, keywordMap.get(subName));
      }
      fromIndex = commaIndex;
    }
    return sbName.toString();
  }
}
origin: spring-projects/spring-data-jpa

  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    for (Attribute<?, ?> attribute : attributes) {
      builder.append(attribute.getName()).append(".");
    }
    return builder.length() == 0 ? "" : builder.substring(0, builder.lastIndexOf("."));
  }
}
origin: yanzhenjie/NoHttp

private <T> Where in(List<T> values) {
  builder.append(Options.IN).append(" (");
  String sep = ", ";
  for (T value : values) {
    if (value instanceof CharSequence)
      builder.append("'").append(value).append("'");
    else if (value instanceof Integer || value instanceof Long || value instanceof Short)
      builder.append(value);
    builder.append(sep);
  }
  if (builder.lastIndexOf(sep) > 0)
    builder.delete(builder.length() - 2, builder.length());
  builder.append(")");
  return this;
}
origin: apache/hive

private CTEClause findCTEFromName(QB qb, String cteName) {
 StringBuilder qId = new StringBuilder();
 if (qb.getId() != null) {
  qId.append(qb.getId());
 }
 while (qId.length() > 0) {
  String nm = qId + ":" + cteName;
  CTEClause cte = aliasToCTEs.get(nm);
  if (cte != null) {
   return cte;
  }
  int lastIndex = qId.lastIndexOf(":");
  lastIndex = lastIndex < 0 ? 0 : lastIndex;
  qId.setLength(lastIndex);
 }
 return aliasToCTEs.get(cteName);
}
origin: alibaba/nacos

public static ConfigInfo merge(String dataId, String group, String tenant, List<ConfigInfoAggr> datumList) {
  StringBuilder sb = new StringBuilder();
  String appName = null;
  for (ConfigInfoAggr aggrInfo : datumList) {
    if (aggrInfo.getAppName() != null) {
      appName = aggrInfo.getAppName();
    }
    sb.append(aggrInfo.getContent());
    sb.append(Constants.NACOS_LINE_SEPARATOR);
  }
  String content = sb.substring(0, sb.lastIndexOf(Constants.NACOS_LINE_SEPARATOR));
  return new ConfigInfo(dataId, group, tenant, appName, content);
}
origin: rest-assured/rest-assured

  public void process( final HttpRequest req,
      final HttpContext context ) throws HttpException, IOException {
    
    // set the Accept-Encoding header:
    String encoding = getContentEncoding();            
    if ( !req.containsHeader( ACCEPT_ENC_HDR ) )
      req.addHeader( ACCEPT_ENC_HDR, encoding );
    else {
      StringBuilder values = new StringBuilder();
      for ( Header h : req.getHeaders( ACCEPT_ENC_HDR ) )
        values.append( h.getValue() ).append( "," );
      String encList = (!values.toString().contains( encoding )) ? values
          .append( encoding ).toString()
          : values.toString().substring( 0, values.lastIndexOf( "," ) );
          
      req.setHeader( ACCEPT_ENC_HDR, encList );
    }
    //TODO compress request and add content-encoding header.
  }
}
origin: ReactiveX/RxJava

static final void scanFor(StringBuilder sourceCode, String annotation, String inDoc,
    StringBuilder e, String baseClassName) {
  int index = 0;
  for (;;) {
    int idx = sourceCode.indexOf(annotation, index);
    if (idx < 0) {
      break;
    }
    int j = sourceCode.lastIndexOf("/**", idx);
    // see if the last /** is not before the index (last time the annotation was found
    // indicating an uncommented method like subscribe()
    if (j > index) {
      int k = sourceCode.indexOf(inDoc, j);
      if (k < 0 || k > idx) {
        // when printed on the console, IDEs will create a clickable link to help navigate to the offending point
        e.append("java.lang.RuntimeException: missing ").append(inDoc).append(" section\r\n")
        ;
        int lc = lineNumber(sourceCode, idx);
        e.append(" at io.reactivex.").append(baseClassName)
        .append(" (").append(baseClassName).append(".java:")
        .append(lc).append(")").append("\r\n\r\n");
      }
    }
    index = idx + annotation.length();
  }
}
origin: ReactiveX/RxJava

int j = sourceCode.lastIndexOf("/**", idx);
java.langStringBuilderlastIndexOf

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
  • replace
  • setCharAt
  • replace,
  • setCharAt,
  • indexOf,
  • reverse,
  • appendCodePoint,
  • getChars,
  • subSequence,
  • ensureCapacity,
  • trimToSize

Popular in Java

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Github Copilot alternatives
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