public static String compressJs ( String code ) { InputStream inStream = new ByteArrayInputStream ( code . getBytes ( ) ) ; ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ; JSMin jsmin = new JSMin ( inStream , outStream ) ; try { jsmin . jsmin ( ) ; return outStream . toString ( ) . trim ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return "" ; } }
Compress a JS - string