Here you can find the source of doubleToSingleQuote(String source)
Parameter | Description |
---|---|
String | source |
public static String doubleToSingleQuote(String source)
//package com.java2s; public class Main { /**/* w w w. java 2 s. c o m*/ * replace " with ' * @param String source * @return String * @exception none */ public static String doubleToSingleQuote(String source) { if (source == null || source.trim().length() == 0) return ""; if (source.indexOf("\"") != -1) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < source.length(); i++) { char c = source.charAt(i); if (c != '\"') { buf.append(c); } else { buf.append("\'"); } } return buf.toString(); } return source; } public static int indexOf(String str, String searchStr) { if (str == null || searchStr == null) { return -1; } return str.indexOf(searchStr); } }