Utils
Posted sunshineicy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Utils相关的知识,希望对你有一定的参考价值。
public static String[] splitBySeparator(String source, String separator) { int startIndex = 0; int endIndex = source.indexOf(separator); Vector vector = new Vector(); for (; endIndex >= startIndex; endIndex = source.indexOf(separator, startIndex)) { vector.add(source.substring(startIndex, endIndex)); startIndex = endIndex + separator.length(); } vector.add(source.substring(startIndex)); String returnValue[] = new String[vector.size()]; vector.copyInto(returnValue); return returnValue; }
public static String replaceAll(String src, String tarStr, String repStr) { int srcPos = 0; int tarPos = 0; StringBuffer result = new StringBuffer(25); while ((tarPos = src.indexOf(tarStr, srcPos)) >= 0) { result.append(src.substring(srcPos, tarPos)); result.append(repStr); srcPos = tarPos + tarStr.length(); } result.append(src.substring(srcPos)); String finalString = result.toString(); return finalString; }
以上是关于Utils的主要内容,如果未能解决你的问题,请参考以下文章
elasticsearch代码片段,及工具类SearchEsUtil.java
VC ++ WINAPI窗体:找不到标识符(C3861错误)
getApplicationContext给出空指针异常[重复]