/*
 * Copyright (c) 2005-2016, Opensmile.  All rights reserved.
 */

package top.opensmile.common;

/**
 * Created by opensmile on 16/10/2.
 */
public class Utils {

    public static String subStrByTheCharFromHead(String original, String thechar) {
        return subStrByTheChar(original, thechar, true);
    }


    /**
     * 对原字符串，根据特定字符进行截取.
     * @param original
     * @param thechar
     * @param isFromHead 是否从头开始，否则截取从指定字符后到尾部
     * @return
     */
    public static String subStrByTheChar(String original , String thechar, boolean isFromHead){
        if(original == null || "".equals(original)) return "";
        int index = original.indexOf(thechar);
        if(index < 0 ) return original;
        if (isFromHead) {
            return original.substring(0, index);
        }else {
            return original.substring(index+thechar.length());
        }
    }

    /**
     * 传进来的 包含Ip字符串，通过正则表达式得到ip
     *  @param ipstr
     * @return
     */
    public static String getIpFromIpstrByPattern(String ipstr) {
        String p_str = "(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})";
        java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(p_str);
        java.util.regex.Matcher matcher = pattern.matcher(ipstr);
        if(matcher.find()) {
            String ip = matcher.group();
            return ip;
        }
        return "";
    }

    public static String[] splitStr(String content,String symbol) {
        String[] array = content.split(symbol);
        return array;
    }

    public static String[] splitStr(String content) {
        return splitStr(content, "&");
    }

}

@@ -1613,10 +1613,407 @@
 %0A    %7D%0A%0A
+    /**%0A     * %E8%8E%B7%E5%8F%96%E9%A1%B9%E7%9B%AE%E7%89%A9%E7%90%86%E8%B7%AF%E5%BE%84%0A     * if %E5%9C%A8%E7%94%9F%E4%BA%A7%E7%8E%AF%E5%A2%83%E4%B8%AD%EF%BC%8C%E4%BD%BF%E7%94%A8startup.sh%E5%90%AF%E5%8A%A8%E9%A1%B9%E7%9B%AE%EF%BC%8C%E9%9C%80%E8%A6%81java%E5%90%AF%E5%8A%A8%E5%8A%A0%E4%B8%8A-Dproject.path%E7%9A%84%E5%8F%82%E6%95%B0%0A     * if %E5%9C%A8%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E4%B8%AD%EF%BC%8C%E4%BD%BF%E7%94%A8%E7%9A%84%E7%B1%BB%E7%9A%84%0A     * @return%0A     */%0A    public static String getProjectAbsolutePath()%7B%0A        String ppath = System.getProperty(%22project.path%22);%0A        if(ppath == null %7C%7C %22%22.equals(ppath))%7B%0A            return Utils.class.getResource(%22/%22).getPath().toString();%0A        %7D%0A        return ppath;%0A    %7D%0A
 %7D%0A

add a method what get project path