• 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;
        }
  • 相关阅读:
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    自学Java0721
  • 原文地址:https://www.cnblogs.com/jingRegina/p/7504878.html
Copyright © 2020-2023  润新知