@Test public void escape(){ StringWriter writer = new StringWriter(); CharEscapeUtil charEscapeUtil = new CustomCharEscapeUtil(writer); charEscapeUtil.writeString("/+\"\\", true); System.out.println(writer.toString()); }
public static String escape(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '=' || c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?' || c == '|' || c == '&' || c == '/') { sb.append('\\'); } sb.append(c); } return sb.toString(); }
CharEscapeUtil { public static String escape(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '=' || c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?' || c == '|' || c == '&' || c == '/') { sb.append('\\'); } sb.append(c); } return sb.toString(); } }
CharEscapeUtil { public static String escape(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '=' || c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?' || c == '|' || c == '&' || c == '/') { sb.append('\\'); } sb.append(c); } return sb.toString(); } CharEscapeUtil( Writer w,int features);  CharEscapeUtil( );  CharEscapeUtil( Writer w); }
CharEscapeUtil { public static String escape(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '=' || c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?' || c == '|' || c == '&' || c == '/') { sb.append('\\'); } sb.append(c); } return sb.toString(); } CharEscapeUtil( Writer w,int features);  CharEscapeUtil( );  CharEscapeUtil( Writer w); Object getOutputTarget(); int getOutputBuffered(); boolean canWriteFormattedNumbers(); void writeString(String text,boolean flush); String toString(); void _writeString(String text); void _writeString2(final int len); static String escape(String s); }
CharEscapeUtil { public static String escape(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '=' || c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?' || c == '|' || c == '&' || c == '/') { sb.append('\\'); } sb.append(c); } return sb.toString(); } CharEscapeUtil( Writer w,int features);  CharEscapeUtil( );  CharEscapeUtil( Writer w); Object getOutputTarget(); int getOutputBuffered(); boolean canWriteFormattedNumbers(); void writeString(String text,boolean flush); String toString(); void _writeString(String text); void _writeString2(final int len); static String escape(String s);  }