tosql.java

来自「这是一个JSP做的主页管理系统」· Java 代码 · 共 53 行

JAVA
53
字号
package com.gbsource.util;/** * Title:        华源网络主页基地管理 * Description: * Copyright:    Copyright (c) 2001 * Company:      Gbsource Studio * @author fishwu * @version 1.0 */public class ToSQL{  public static String WriteToSQL(String s)  {    s = Replace(s,"[","[[]");    s = Replace(s,"'","''");    s = Replace(s,"_","[_]");    s = Replace(s,"%","[%]");    return s;  }  public static String WriteHtml(String s)  {    s = Replace(s,"&","&amp;");    s = Replace(s,"<","&lt;");    s = Replace(s,">","&gt;");    s = Replace(s,"\t","    ");    s = Replace(s,"\r\n","\n");    s = Replace(s,"\n","<br>");    s = Replace(s,"  "," &nbsp;");    return s;  }  public static String Replace(String source,String oldString,String newString)  {    if(source == null) return null;    StringBuffer output = new StringBuffer();    int lengOfsource = source.length();    int lengOfold = oldString.length();    int posStart = 0;    int pos;    while((pos = source.indexOf(oldString,posStart)) >= 0)    {      output.append(source.substring(posStart,pos));      output.append(newString);      posStart = pos + lengOfold;    }    if(posStart < lengOfsource)    {      output.append(source.substring(posStart));    }    return output.toString();  }}

⌨️ 快捷键说明

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