⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 library.java

📁 httptunnel.jar httptunnel java 源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * @param d     * @param p     *     * @return     */    public static double truncate(double d, int p) {        double f = Math.pow(10., p);        double g = d * f;        return ((d < 0) ? Math.ceil(g)                        : Math.floor(g)) / f;    }    /**     * Method declaration     *     *     * @param i     * @param j     *     * @return     */    public static int bitand(int i, int j) {        return i & j;    }    /**     * Method declaration     *     *     * @param i     * @param j     *     * @return     */    public static int bitor(int i, int j) {        return i | j;    }    // STRING    /**     * Method declaration     *     *     * @param s     *     * @return     */    public static Integer ascii(String s) {        if ((s == null) || (s.length() == 0)) {            return null;        }        return new Integer(s.charAt(0));    }    /**     * Method declaration     *     *     * @param code     *     * @return     */    public static String character(int code) {        return String.valueOf((char) code);    }    /**     * Method declaration     *     *     * @param s1     * @param s2     *     * @return     */    public static String concat(String s1, String s2) {        if (s1 == null) {            if (s2 == null) {                return null;            }            return s2;        }        if (s2 == null) {            return s1;        }        return s1 + s2;    }    /**     * Method declaration     *     *     * @param s1     * @param s2     *     * @return     */// fredt@users 20020305 - patch 460907 by fredt - soundex    public static int difference(String s1, String s2) {        // todo: check if this is the standard algorithm        if ((s1 == null) || (s2 == null)) {            return 0;        }        s1 = soundex(s1);        s2 = soundex(s2);        int e = 0;        for (int i = 0; i < 4; i++) {            if (s1.charAt(i) != s2.charAt(i)) {                e++;            }        }        return e;    }    /**     * Method declaration     *     *     * @param s     *     * @return     */    public static String hexToRaw(String s) {        char         raw;        StringBuffer to  = new StringBuffer();        int          len = s.length();        if (len % 4 != 0) {            return null;        }        for (int i = 0; i < len; i += 4) {            raw = (char) Integer.parseInt(s.substring(i, i + 4), 16);            to.append(raw);        }        return (to.toString());    }    /**     * Method declaration     *     *     * @param s1     * @param start     * @param length     * @param s2     *     * @return     */    public static String insert(String s1, int start, int length, String s2) {        if (s1 == null) {            return s2;        }        if (s2 == null) {            return s1;        }        int len1 = s1.length();        int len2 = s2.length();        start--;        if (start < 0 || length <= 0 || len2 == 0 || start > len1) {            return s1;        }        if (start + length > len1) {            length = len1 - start;        }        return s1.substring(0, start) + s2 + s1.substring(start + length);    }    /**     * Method declaration     *     *     * @param s     *     * @return     */    public static String lcase(String s) {        return (s == null) ? null                           : s.toLowerCase();    }    /**     * Method declaration     *     *     * @param s     * @param i     *     * @return     */    public static String left(String s, int i) {        if (s == null) {            return null;        }        return s.substring(0, ((i < 0) ? 0                                       : (i < s.length()) ? i                                                          : s.length()));    }// fredt@users - 20020819 - patch 595854 by thomasm@users    /**     *  Method declaration     *     *     *  @param s     *     *  @return     */    public static Integer length(String s) {        return s == null ? null                         : new Integer(s.length());    }    /**     * Method declaration     *     *     * @param search     * @param s     * @param start     *     * @return     */    public static int locate(String search, String s, Integer start) {        if (s == null || search == null) {            return 0;        }        int i = (start == null) ? 0                                : start.intValue() - 1;        return s.indexOf(search, (i < 0) ? 0                                         : i) + 1;    }    /**     * Method declaration     *     *     * @param s     *     * @return     */    public static String ltrim(String s) {        if (s == null) {            return s;        }        int len = s.length(),            i   = 0;        while (i < len && s.charAt(i) <= ' ') {            i++;        }        return (i == 0) ? s                        : s.substring(i);    }    /**     * Method declaration     *     *     * @param s     *     * @return     */    public static String rawToHex(String s) {        char         from[] = s.toCharArray();        String       hex;        StringBuffer to = new StringBuffer();        for (int i = 0; i < from.length; i++) {            hex = Integer.toHexString(from[i] & 0xffff);            for (int j = hex.length(); j < 4; j++) {                to.append('0');            }            to.append(hex);        }        return (to.toString());    }    /**     * Method declaration     *     *     * @param s     * @param i     *     * @return     */    public static String repeat(String s, Integer count) {        if (s == null || count == null || count.intValue() < 0) {            return null;        }        int          i = count.intValue();        StringBuffer b = new StringBuffer(s.length() * i);        while (i-- > 0) {            b.append(s);        }        return b.toString();    }// fredt@users - 20020903 - patch 1.7.1 - bug fix to allow multiple replaces    /**     * Method declaration     *     *     * @param s     * @param replace     * @param with     *     * @return     */    public static String replace(String s, String replace, String with) {        if (s == null || replace == null) {            return s;        }        if (with == null) {            with = "";        }        StringBuffer b          = new StringBuffer();        int          start      = 0;        int          lenreplace = replace.length();        while (true) {            int i = s.indexOf(replace, start);            if (i == -1) {                b.append(s.substring(start));                break;            }            b.append(s.substring(start, i));            b.append(with);            start = i + lenreplace;        }        return b.toString();    }    /**     * Method declaration     *     *     * @param s     * @param i     *     * @return     */    public static String right(String s, int i) {        if (s == null) {            return null;        }        i = s.length() - i;        return s.substring((i < 0) ? 0                                   : (i < s.length()) ? i                                                      : s.length());    }// fredt@users 20020530 - patch 1.7.0 fredt - trim only the space character    /**     * Method declaration     *     *     * @param s     *     * @return     */    public static String rtrim(String s) {        if (s == null) {            return s;        }        int endindex = s.length() - 1;        int i        = endindex;        for (; i >= 0 && s.charAt(i) == ' '; i--) {}        return i == endindex ? s                             : s.substring(0, i + 1);    }// fredt@users 20011010 - patch 460907 by fredt - soundex    /**     * code was rewritten by fredt@users to comply with description at     * http://www.nara.gov/genealogy/coding.html     * non ASCCI characters in string are ignored     *     * @param s     *     * @return     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -