From 01909541d05b8196c6adf9a03e135d8a7a745dba Mon Sep 17 00:00:00 2001 From: kang0921ok Date: Sat, 3 Jun 2017 23:31:02 +0900 Subject: [PATCH] [ADD] File merge function --- .../yui/compressor/YUICompressor.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/com/yahoo/platform/yui/compressor/YUICompressor.java b/src/com/yahoo/platform/yui/compressor/YUICompressor.java index 46d60f5a..372e2ade 100644 --- a/src/com/yahoo/platform/yui/compressor/YUICompressor.java +++ b/src/com/yahoo/platform/yui/compressor/YUICompressor.java @@ -34,7 +34,7 @@ public static void main(String args[]) { CmdLineParser.Option preserveUnknownHintsOpt = parser.addBooleanOption('p', "preservehints"); Reader in = null; - Writer out = null; + BufferedWriter out = null; Writer mungemap = null; try { @@ -113,7 +113,7 @@ public static void main(String args[]) { } else { pattern = output.split(":"); } - + try { String mungemapFilename = (String) parser.getOptionValue(mungemapFilenameOpt); if (mungemapFilename != null) { @@ -168,7 +168,7 @@ public static void main(String args[]) { JavaScriptCompressor compressor = new JavaScriptCompressor(in, new ErrorReporter() { public void warning(String message, String sourceName, - int line, String lineSource, int lineOffset) { + int line, String lineSource, int lineOffset) { System.err.println("\n[WARNING] in " + localFilename); if (line < 0) { System.err.println(" " + message); @@ -178,7 +178,7 @@ public void warning(String message, String sourceName, } public void error(String message, String sourceName, - int line, String lineSource, int lineOffset) { + int line, String lineSource, int lineOffset) { System.err.println("[ERROR] in " + localFilename); if (line < 0) { System.err.println(" " + message); @@ -188,7 +188,7 @@ public void error(String message, String sourceName, } public EvaluatorException runtimeError(String message, String sourceName, - int line, String lineSource, int lineOffset) { + int line, String lineSource, int lineOffset) { error(message, sourceName, line, lineSource, lineOffset); return new EvaluatorException(message); } @@ -199,9 +199,10 @@ public EvaluatorException runtimeError(String message, String sourceName, in.close(); in = null; if (outputFilename == null) { - out = new OutputStreamWriter(System.out, charset); + out = new BufferedWriter(new OutputStreamWriter(System.out, charset)); } else { - out = new OutputStreamWriter(new FileOutputStream(outputFilename), charset); + out = new BufferedWriter + (new OutputStreamWriter(new FileOutputStream(outputFilename, true), charset)); if (mungemap != null) { mungemap.write("\n\nFile: "+outputFilename+"\n\n"); } @@ -227,9 +228,10 @@ public EvaluatorException runtimeError(String message, String sourceName, in.close(); in = null; if (outputFilename == null) { - out = new OutputStreamWriter(System.out, charset); - } else { - out = new OutputStreamWriter(new FileOutputStream(outputFilename), charset); + out = new BufferedWriter(new OutputStreamWriter(System.out, charset)); + } else { + out = new BufferedWriter + (new OutputStreamWriter(new FileOutputStream(outputFilename), charset)); } compressor.compress(out, linebreakpos); @@ -306,4 +308,4 @@ private static void usage() { + "option is required. Otherwise, the 'type' option is required only if the input\n" + "file extension is neither 'js' nor 'css'."); } -} +} \ No newline at end of file