/** * Removes the quoting around a String. * @param s The String that may have enclosing quotes * @return The String resulting from removing the enclosing quotes */ public static String removeEnclosingQuotes(String s) { if (s == null) return null; if (isDoubleQuoted(s) || isSingleQuoted(s)) { return s.substring(1, s.length() - 1); } return s; }
/** * Removes the quoting around a String. * @param s The String that may have enclosing quotes * @return The String resulting from removing the enclosing quotes */ public static String removeEnclosingQuotes(String s) { if (s == null) return null; if (isDoubleQuoted(s) || isSingleQuoted(s)) { return s.substring(1, s.length() - 1); } return s; }
/** * Removes the quoting around a String. * @param s The String that may have enclosing quotes * @return The String resulting from removing the enclosing quotes */ public static String removeEnclosingQuotes(String s) { if (s == null) return null; if (isDoubleQuoted(s) || isSingleQuoted(s)) { return s.substring(1, s.length() - 1); } return s; }
/** * Nightmares can result from using a path with a space in it! * This method will enclose in the specified quote characters if needed. * @param path * @return */ public static String quotePathIfNecessary(String path, char quoteChar) { if (!ok(path) || !needsQuoting(path) || isDoubleQuoted(path) || isSingleQuoted(path)) return path; // needs quoting! StringBuilder sb = new StringBuilder(); sb.append(quoteChar); sb.append(path); sb.append(quoteChar); return sb.toString(); }
/** * Nightmares can result from using a path with a space in it! * This method will enclose in the specified quote characters if needed. * @param path * @return */ public static String quotePathIfNecessary(String path, char quoteChar) { if (!ok(path) || !needsQuoting(path) || isDoubleQuoted(path) || isSingleQuoted(path)) return path; // needs quoting! StringBuilder sb = new StringBuilder(); sb.append(quoteChar); sb.append(path); sb.append(quoteChar); return sb.toString(); }