Here you can find the source of quoteRemarkSQL(String sql)
Parameter | Description |
---|---|
sql | the string |
public static String quoteRemarkSQL(String sql)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w.j ava 2 s .c om*/ * In a string, replace block comment marks with /++ .. ++/. * * @param sql the string * @return the resulting string */ public static String quoteRemarkSQL(String sql) { sql = replaceAll(sql, "*/", "++/"); return replaceAll(sql, "/*", "/++"); } /** * Replace all occurrences of the before string with the after string. * * @param s the string * @param before the old text * @param after the new text * @return the string with the before string replaced */ public static String replaceAll(String s, String before, String after) { int next = s.indexOf(before); if (next < 0) { return s; } StringBuilder buff = new StringBuilder(s.length() - before.length() + after.length()); int index = 0; while (true) { buff.append(s.substring(index, next)).append(after); index = next + before.length(); next = s.indexOf(before, index); if (next < 0) { buff.append(s.substring(index)); break; } } return buff.toString(); } }