File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed
arduino-core/src/processing/app/legacy Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -552,23 +552,20 @@ static final public String[] str(int x[]) {
552552 /**
553553 * I want to print lines to a file. I have RSI from typing these
554554 * eight lines of code so many times.
555+ * @throws IOException
555556 */
556- static public PrintWriter createWriter (File file ) {
557+ static public PrintWriter createWriter (File file ) throws IOException {
558+ createPath (file ); // make sure in-between folders exist
559+ OutputStream output = new FileOutputStream (file );
557560 try {
558- createPath (file ); // make sure in-between folders exist
559- OutputStream output = new FileOutputStream (file );
560561 if (file .getName ().toLowerCase ().endsWith (".gz" )) {
561562 output = new GZIPOutputStream (output );
562563 }
563- return createWriter (output );
564-
565- } catch (Exception e ) {
566- if (file == null ) {
567- throw new RuntimeException ("File passed to createWriter() was null" );
568- } else {
569- throw new RuntimeException ("Couldn't create a writer for " + file .getAbsolutePath (), e );
570- }
564+ } catch (IOException e ) {
565+ output .close ();
566+ throw e ;
571567 }
568+ return createWriter (output );
572569 }
573570
574571
You can’t perform that action at this time.
0 commit comments