1 17 package net.sf.packtag.implementation; 18 19 import java.io.BufferedInputStream ; 20 import java.io.ByteArrayOutputStream ; 21 import java.io.InputStream ; 22 23 import net.sf.packtag.strategy.PackException; 24 import net.sf.packtag.strategy.PackStrategy; 25 26 27 28 29 36 public class JsminPackStrategy implements PackStrategy { 37 38 public String pack(InputStream resourceAsStream) throws PackException { 39 BufferedInputStream bis = new BufferedInputStream (resourceAsStream); 40 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 41 JSMin min = new JSMin(bis, baos); 42 try { 43 min.jsmin(); 44 return new String (baos.toByteArray()).trim(); 45 } 46 catch (Exception ex) { 47 throw new PackException("Could not pack resource", ex); 48 } 49 } 50 51 } 52 | Popular Tags |