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

📄 string.java

📁 企业办公自动化管理系统
💻 JAVA
字号:
package com.zh.util;

import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

public class string
{

    public string()
    {
    }

    public String HtmlDecode(String s)
    {
        s = Replace(s, "<p>", "\n\r\n\r");
        s = Replace(s, "</p>", "\n\r\n\r");
        s = Replace(s, "<br>", "\n\r");
        s = Replace(s, "\r", "<BR>");
        return s;
    }

    public String HtmlEncode(String s)
    {
        s = Replace(s, ">", "&gt;");
        s = Replace(s, "<", "&lt;");
        s = Replace(s, "\n", "");
        s = Replace(s, "\r\r", "</P><P>");
        s = Replace(s, "\r", "<BR>");
        return s;
    }

    public String RemoveBadHtml(String s)
    {
        String s1 = "";
        s = s.toLowerCase();
        int i = 0;
        boolean flag = false;
        boolean flag1 = false;
        boolean flag2 = false;
        i = s.indexOf("<script");
        for(int j = s.indexOf("</script>"); i != -1 && i != -1; j = s.indexOf("</script>", j + 9))
        {
            String s2 = s.substring(i, j + 9);
            s = Replace(s, s2, "");
            i = s.indexOf("<script", j + 8);
        }

        i = s.indexOf("<object");
        for(int k = s.indexOf("</object>"); i != -1 && i != -1; k = s.indexOf("</object>", k + 9))
        {
            String s3 = s.substring(i, k + 9);
            s = Replace(s, s3, "");
            i = s.indexOf("<object", k + 9);
        }

        return s;
    }

    public String Replace(String s, String s1, String s2)
    {
        String s3 = "";
        int i = s.indexOf(s1);
        if(i == -1)
            return s;
        int j;
        int k;
        for(k = 0; (j = s.indexOf(s1, k)) != -1; k = j + s1.length())
        {
            s3 = s3 + s.substring(k, j);
            s3 = s3 + s2;
        }

        s3 = s3 + s.substring(k, s.length());
        return s3;
    }

    public String from_8859_1(String s)
    {
        if(s == null)
            return null;
        String s2;
        try
        {
            String s1 = new String(s.getBytes("iso-8859-1"));
            return s1;
        }
        catch(Exception _ex)
        {
            s2 = null;
        }
        return s2;
    }

    public String msgBox(String s, String s1)
    {
        String s2 = "<body bgcolor=#d6d3ce><div  align=center><table border=1 bordercolorlight=#000000 bordercolordark=#FFFFFF cellspacing=0 bgcolor=#E0E0E0>\n";
        s2 = s2 + "<tr><td><table border=0 bgcolor=#0066CC cellspacing=0 cellpadding=2 width=350><tr>\n";
        s2 = s2 + "<td width=342><font color=#FFFFFF>\244" + s1 + "</font></td><td width=18>&nbsp; </td>\n";
        s2 = s2 + "</tr></table><table border=0 width=350 cellpadding=4><tr><td width=59 align=center valign=top>\n";
        s2 = s2 + "<font face=Wingdings color=#FF0000 style=\"font-size:32pt\">L</font></td><td width=269>\n";
        s2 = s2 + "<p align=center>" + s + "</p></td></tr><tr>\n";
        s2 = s2 + "<td colspan=2 align=center valign=top><input type=button name=ok value=\"\u3000\u786E \u5B9A\u3000\" onclick(=\"javascript:history.back()\"></td>\n";
        s2 = s2 + "</tr>\n</table>\n</td></tr></table></div>\n";
        return s2;
    }

    public String rtnfun(String s, int i)
    {
        String s1 = "\n<SCRIPT language=javascript>\nvar bar=0;\ncount();\nfunction count(){\n\tbar=bar+2;\n\tif (bar<99)\n\t\tsetTimeout('count()'," + i + ");\n" + "\telse\n" + "\t\twindow.location = '" + s + "';\n" + "}\n</SCRIPT>\n";
        return s1;
    }

    public void setGBbyte()
    {
        isGbByte = true;
    }

    public String showMsg(String s, String s1, String s2)
    {
        String s3 = rtnfun(s, 60);
        s3 = s3 + "<body bgcolor=#d6d3ce><div  align=center><table border=1 bordercolorlight=#000000 bordercolordark=#FFFFFF cellspacing=0 bgcolor=#E0E0E0>\n";
        s3 = s3 + "<tr><td><table border=0 bgcolor=#0066CC cellspacing=0 cellpadding=2 width=350><tr>\n";
        s3 = s3 + "<td width=342><font color=#FFFFFF>\244" + s2 + "</font></td><td width=18>&nbsp; </td>\n";
        s3 = s3 + "</tr></table><table border=0 width=350 cellpadding=4><tr><td width=59 align=center valign=top>\n";
        s3 = s3 + "<font face=Wingdings color=#FF0000 style=\"font-size:32pt\">L</font></td><td width=269>\n";
        s3 = s3 + "<p align=center>" + s1 + "</p></td></tr><tr>\n";
        s3 = s3 + "<td colspan=2 align=center valign=top><input type=button name=ok value=\"\u3000\u786E \u5B9A\u3000\" onclick=\"" + s + "\"></td>\n";
        s3 = s3 + "</tr>\n</table>\n</td></tr></table></div>\n";
        return s3;
    }

    public String toByteString(String s)
    {
        if(s == null)
            return null;
        if(s.length() == 0)
            return "";
        char ac[] = s.toCharArray();
        byte abyte0[] = new byte[s.length() * 2];
        int i = 0;
        int j = ac.length;
        int k = 0;
        boolean flag = false;
        for(; k < j && i < j * 2; k++)
        {
            char c = ac[k];
            if(c > '\377')
            {
                try
                {
                    byte abyte1[] = (new Character(ac[k])).toString().getBytes("GB2312");
                    for(int l = 0; l < abyte1.length; l++)
                    {
                        abyte0[i] = abyte1[l];
                        i++;
                    }

                }
                catch(Exception exception)
                {
                    exception.printStackTrace();
                }
            }
            else
            {
                abyte0[i] = (byte)ac[k];
                i++;
            }
        }

        return new String(abyte0, 0, i);
    }

    public String toChinese(String s)
    {
        if(s == null)
            return null;
        String s1 = null;
        try
        {
            if(!isGbByte)
            {
                byte abyte0[] = s.getBytes("iso-8859-1");
                s1 = new String(abyte0);
            }
            else
            {
                return s;
            }
        }
        catch(UnsupportedEncodingException unsupportedencodingexception)
        {
            System.err.println(unsupportedencodingexception.toString());
        }
        return s1;
    }

    public String to_8859(String s)
    {
        if(s == null)
            return null;
        String s1 = null;
        try
        {
            if(isGbByte)
            {
                byte abyte0[] = s.getBytes("GB2312");
                s1 = new String(abyte0);
            }
            else
            {
                return s;
            }
        }
        catch(UnsupportedEncodingException unsupportedencodingexception)
        {
            System.err.println(unsupportedencodingexception.toString());
        }
        return s1;
    }

    public String to_8859_1(String s)
    {
        if(s == null)
            return null;
        try
        {
            if(!isGbByte)
                return new String(s.getBytes(), "iso-8859-1");
            else
                return s;
        }
        catch(Exception _ex)
        {
            String s1 = null;
            return s1;
        }
    }

    private static boolean isGbByte = false;

}

⌨️ 快捷键说明

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