File tree 1 file changed +8
-11
lines changed
arduino-core/src/processing/app/legacy
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[]) {
552
552
/**
553
553
* I want to print lines to a file. I have RSI from typing these
554
554
* eight lines of code so many times.
555
+ * @throws IOException
555
556
*/
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 );
557
560
try {
558
- createPath (file ); // make sure in-between folders exist
559
- OutputStream output = new FileOutputStream (file );
560
561
if (file .getName ().toLowerCase ().endsWith (".gz" )) {
561
562
output = new GZIPOutputStream (output );
562
563
}
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 ;
571
567
}
568
+ return createWriter (output );
572
569
}
573
570
574
571
You can’t perform that action at this time.
0 commit comments