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

📄 filt.java

📁 这个也是关于图书管理系统的代码
💻 JAVA
字号:
package com.xmspk.ebp.test;
/**
 * Created by IntelliJ IDEA.
 * User: 颜才顶
 * Date: 2003-4-29
 * Time: 16:16:03
 * To change this template use Options | File Templates.
 */
public class Filt
{
        public Filt(){
        }

        public static String Encode(String source)
        //过滤非法字符 ,不保证<br>
        {
                if (source==null)
                        return "";
                StringBuffer buf = new StringBuffer(source);
                char c=0;
                int i=0;
                int j=0;
                int len = source.length();
                while (j<len)
                {
                        c = source.charAt(j);
                        j++;
                         if (c=='&')
                        {
                                buf.insert(i,"&#38");
                                buf.setCharAt(i+4,';');
                                i+=5;
                        }else if (c=='<')
                        {
                                buf.insert(i,"&lt");
                                buf.setCharAt(i+3,';');
                                i+=4;
                        }else if (c=='>')
                        {
                                buf.insert(i,"&gt");
                                buf.setCharAt(i+3,';');
                                i+=4;
                        }else if (c=='"')
                        {
                                buf.insert(i,"&quot");
                                buf.setCharAt(i+5,';');
                                i+=6;
                        }else
                                i++;
                }
                return buf.toString();

        }

    public static String Encode1(String source)
    //过滤非法字符 ,保证<br>
    {
            if (source==null)
                    return "";
            StringBuffer buf = new StringBuffer(source);
            char c=0;
            int i=0;
            int j=0;
            int len = source.length();
            while (j<len)
            {
                    c = source.charAt(j);
                    j++;
                     if (c=='&')
                    {
                            buf.insert(i,"&#38");
                            buf.setCharAt(i+4,';');
                            i+=5;
                    }else if (c=='\n')
                    {
                            buf.insert(i,"<br");
                            buf.setCharAt(i+3,'>');
                            i+=4;
                    }else if (c=='<')
                    {
                            buf.insert(i,"&lt");
                            buf.setCharAt(i+3,';');
                            i+=4;
                    }else if (c=='>')
                    {
                            buf.insert(i,"&gt");
                            buf.setCharAt(i+3,';');
                            i+=4;
                    }else if (c=='"')
                    {
                            buf.insert(i,"&quot");
                            buf.setCharAt(i+5,';');
                            i+=6;
                    }else
                            i++;
            }
            return buf.toString();

    }


}

⌨️ 快捷键说明

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