@@ -34,7 +34,7 @@ public static void main(String args[]) {
3434 CmdLineParser .Option preserveUnknownHintsOpt = parser .addBooleanOption ('p' , "preservehints" );
3535
3636 Reader in = null ;
37- Writer out = null ;
37+ BufferedWriter out = null ;
3838 Writer mungemap = null ;
3939
4040 try {
@@ -113,7 +113,7 @@ public static void main(String args[]) {
113113 } else {
114114 pattern = output .split (":" );
115115 }
116-
116+
117117 try {
118118 String mungemapFilename = (String ) parser .getOptionValue (mungemapFilenameOpt );
119119 if (mungemapFilename != null ) {
@@ -168,7 +168,7 @@ public static void main(String args[]) {
168168 JavaScriptCompressor compressor = new JavaScriptCompressor (in , new ErrorReporter () {
169169
170170 public void warning (String message , String sourceName ,
171- int line , String lineSource , int lineOffset ) {
171+ int line , String lineSource , int lineOffset ) {
172172 System .err .println ("\n [WARNING] in " + localFilename );
173173 if (line < 0 ) {
174174 System .err .println (" " + message );
@@ -178,7 +178,7 @@ public void warning(String message, String sourceName,
178178 }
179179
180180 public void error (String message , String sourceName ,
181- int line , String lineSource , int lineOffset ) {
181+ int line , String lineSource , int lineOffset ) {
182182 System .err .println ("[ERROR] in " + localFilename );
183183 if (line < 0 ) {
184184 System .err .println (" " + message );
@@ -188,7 +188,7 @@ public void error(String message, String sourceName,
188188 }
189189
190190 public EvaluatorException runtimeError (String message , String sourceName ,
191- int line , String lineSource , int lineOffset ) {
191+ int line , String lineSource , int lineOffset ) {
192192 error (message , sourceName , line , lineSource , lineOffset );
193193 return new EvaluatorException (message );
194194 }
@@ -199,9 +199,10 @@ public EvaluatorException runtimeError(String message, String sourceName,
199199 in .close (); in = null ;
200200
201201 if (outputFilename == null ) {
202- out = new OutputStreamWriter (System .out , charset );
202+ out = new BufferedWriter ( new OutputStreamWriter (System .out , charset ) );
203203 } else {
204- out = new OutputStreamWriter (new FileOutputStream (outputFilename ), charset );
204+ out = new BufferedWriter
205+ (new OutputStreamWriter (new FileOutputStream (outputFilename , true ), charset ));
205206 if (mungemap != null ) {
206207 mungemap .write ("\n \n File: " +outputFilename +"\n \n " );
207208 }
@@ -227,9 +228,10 @@ public EvaluatorException runtimeError(String message, String sourceName,
227228 in .close (); in = null ;
228229
229230 if (outputFilename == null ) {
230- out = new OutputStreamWriter (System .out , charset );
231- } else {
232- out = new OutputStreamWriter (new FileOutputStream (outputFilename ), charset );
231+ out = new BufferedWriter (new OutputStreamWriter (System .out , charset ));
232+ } else {
233+ out = new BufferedWriter
234+ (new OutputStreamWriter (new FileOutputStream (outputFilename ), charset ));
233235 }
234236
235237 compressor .compress (out , linebreakpos );
@@ -306,4 +308,4 @@ private static void usage() {
306308 + "option is required. Otherwise, the 'type' option is required only if the input\n "
307309 + "file extension is neither 'js' nor 'css'." );
308310 }
309- }
311+ }
0 commit comments