// prepare output file
outFile.getParentFile().mkdirs();
Writer out = new OutputStreamWriter(new FileOutputStream(outFile), charset);
if (fileType.equals(FileType.JS_FILE)) {
final JavaScriptCompressor compressor = createJavaScriptCompressor(in);
compressor.compress(out, lineBreakPosition, munge, warn, preserveAllSemiColons, !optimize);
} else if (fileType.equals(FileType.CSS_FILE)) {
final CssCompressor compressor = new CssCompressor(in);
compressor.compress(out, lineBreakPosition);
} else if (fileType.equals(FileType.HTML_FILE) || fileType.equals(FileType.XHTML_FILE)) {
final HtmlCompressor compressor = new HtmlCompressor();
out.write(compressor.compress(readerToString(in)));
} else if (fileType.equals(FileType.XML_FILE)){
final XmlCompressor compressor = new XmlCompressor();
out.write(compressor.compress(readerToString(in)));
}
// close all streams
in.close();
in = null;