public static String escapeQueryString(String unescString){
  if (unescString == null)   return null;
  String escString="";
  String shellSpChars="&;`'\"|*?~<>^()[]{}$\\\n";
  for (int index=0; index < unescString.length(); index++) {
    char nextChar=unescString.charAt(index);
    if (shellSpChars.indexOf(nextChar) != -1)     escString+="\\";
    escString+=nextChar;
  }
  return escString;
}

public static String escapeQueryString ( String unescString ) { if ( unescString == null ) return null ; String escString = "" ; String shellSpChars = "&;`'\"|*?~<>^()[]{}$\\\n" ; for ( int index = 0 ; index < unescString . length ( ) ; index ++ ) { char nextChar = unescString . charAt ( index ) ; if ( shellSpChars . indexOf ( nextChar ) != - 1 ) escString += "\\" ; escString += nextChar ; } return escString ; }
escape special shell characters .
