public static String quoteHtmlChars ( String item ) { if ( item == null ) { return null ; } byte [ ] bytes = item . getBytes ( ) ; if ( needsQuoting ( bytes , 0 , bytes . length ) ) { ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; try { quoteHtmlChars ( buffer , bytes , 0 , bytes . length ) ; } catch ( IOException ioe ) { // Won't happen, since it is a bytearrayoutputstream } return buffer . toString ( ) ; } else { return item ; } }
Quote the given item to make it html - safe .