Here you can find the source of escapeUnixChar(String strToEscape)
public static String escapeUnixChar(String strToEscape)
//package com.java2s; //License from project: Apache License import java.text.StringCharacterIterator; public class Main { public static String escapeUnixChar(String strToEscape) { StringCharacterIterator charIter = new StringCharacterIterator( strToEscape);//from w ww . ja v a 2 s . c om StringBuilder buf = new StringBuilder(); char ch = charIter.current(); while (ch != 65535) { if (ch == ';') buf.append("\\;"); else if (ch == '&') buf.append("\\&"); else if (ch == '(') buf.append("\\("); else if (ch == ')') buf.append("\\)"); else if (ch == '|') buf.append("\\|"); else if (ch == '*') buf.append("\\*"); else if (ch == '?') buf.append("\\?"); else if (ch == '[') buf.append("\\["); else if (ch == ']') buf.append("\\]"); else if (ch == '~') buf.append("\\~"); else if (ch == '{') buf.append("\\{"); else if (ch == '}') buf.append("\\}"); else if (ch == '>') buf.append("\\>"); else if (ch == '<') buf.append("\\<"); else if (ch == '^') buf.append("\\^"); else if (ch == '"') buf.append("\\\""); else if (ch == '$') buf.append("\\$"); else buf.append(ch); ch = charIter.next(); } return buf.toString(); } }