@@ -1508,17 +1508,17 @@ protected PGraphics makeGraphics(int w, int h,
1508
1508
try {
1509
1509
pg = (PGraphics ) constructor .newInstance ();
1510
1510
} catch (InvocationTargetException e ) {
1511
- e . printStackTrace ();
1511
+ printStackTrace (e );
1512
1512
throw new RuntimeException (e .getMessage ());
1513
1513
} catch (IllegalAccessException e ) {
1514
- e . printStackTrace ();
1514
+ printStackTrace (e );
1515
1515
throw new RuntimeException (e .getMessage ());
1516
1516
} catch (InstantiationException e ) {
1517
- e . printStackTrace ();
1517
+ printStackTrace (e );
1518
1518
throw new RuntimeException (e .getMessage ());
1519
1519
} catch (IllegalArgumentException e ) {
1520
1520
// TODO Auto-generated catch block
1521
- e . printStackTrace ();
1521
+ printStackTrace (e );
1522
1522
}
1523
1523
}
1524
1524
}
@@ -2716,7 +2716,6 @@ static public Process exec(String[] argv) {
2716
2716
try {
2717
2717
return Runtime .getRuntime ().exec (argv );
2718
2718
} catch (Exception e ) {
2719
- e .printStackTrace ();
2720
2719
throw new RuntimeException ("Could not open " + join (argv , ' ' ));
2721
2720
}
2722
2721
}
@@ -2725,6 +2724,15 @@ static public Process exec(String[] argv) {
2725
2724
//////////////////////////////////////////////////////////////
2726
2725
2727
2726
2727
+ /**
2728
+ * Better way of handling e.printStackTrace() calls so that they can be
2729
+ * handled by subclasses as necessary.
2730
+ */
2731
+ protected void printStackTrace (Throwable t ) {
2732
+ t .printStackTrace ();
2733
+ }
2734
+
2735
+
2728
2736
/**
2729
2737
* Function for an applet/application to kill itself and
2730
2738
* display an error. Mostly this is here to be improved later.
@@ -2823,16 +2831,16 @@ public void method(String name) {
2823
2831
method .invoke (this , new Object [] { });
2824
2832
2825
2833
} catch (IllegalArgumentException e ) {
2826
- e . printStackTrace ();
2834
+ printStackTrace (e );
2827
2835
} catch (IllegalAccessException e ) {
2828
- e . printStackTrace ();
2836
+ printStackTrace (e );
2829
2837
} catch (InvocationTargetException e ) {
2830
2838
e .getTargetException ().printStackTrace ();
2831
2839
} catch (NoSuchMethodException nsme ) {
2832
2840
System .err .println ("There is no public " + name + "() method " +
2833
2841
"in the class " + getClass ().getName ());
2834
2842
} catch (Exception e ) {
2835
- e . printStackTrace ();
2843
+ printStackTrace (e );
2836
2844
}
2837
2845
}
2838
2846
@@ -3959,7 +3967,7 @@ public XML createXML(String name) {
3959
3967
try {
3960
3968
return new XML (name );
3961
3969
} catch (Exception e ) {
3962
- e . printStackTrace ();
3970
+ printStackTrace (e );
3963
3971
return null ;
3964
3972
}
3965
3973
}
@@ -3983,7 +3991,7 @@ public XML loadXML(String filename, String options) {
3983
3991
try {
3984
3992
return new XML (createInput (filename ), options );
3985
3993
} catch (Exception e ) {
3986
- e . printStackTrace ();
3994
+ printStackTrace (e );
3987
3995
return null ;
3988
3996
}
3989
3997
}
@@ -3998,7 +4006,7 @@ public XML parseXML(String xmlString, String options) {
3998
4006
try {
3999
4007
return XML .parse (xmlString , options );
4000
4008
} catch (Exception e ) {
4001
- e . printStackTrace ();
4009
+ printStackTrace (e );
4002
4010
return null ;
4003
4011
}
4004
4012
}
@@ -4145,7 +4153,7 @@ public Table loadTable(String filename, String options) {
4145
4153
return new Table (createInput (filename ), options );
4146
4154
4147
4155
} catch (IOException e ) {
4148
- e . printStackTrace ();
4156
+ printStackTrace (e );
4149
4157
return null ;
4150
4158
}
4151
4159
}
@@ -4161,7 +4169,7 @@ public boolean saveTable(Table table, String filename, String options) {
4161
4169
table .save (saveFile (filename ), options );
4162
4170
return true ;
4163
4171
} catch (IOException e ) {
4164
- e . printStackTrace ();
4172
+ printStackTrace (e );
4165
4173
}
4166
4174
return false ;
4167
4175
}
@@ -4681,15 +4689,18 @@ static public PrintWriter createWriter(OutputStream output) {
4681
4689
*/
4682
4690
public InputStream createInput (String filename ) {
4683
4691
InputStream input = createInputRaw (filename );
4684
- if ((input != null ) && filename .toLowerCase ().endsWith (".gz" )) {
4692
+ final String lower = filename .toLowerCase ();
4693
+ if ((input != null ) &&
4694
+ (lower .endsWith (".gz" ) || lower .endsWith (".svgz" ))) {
4685
4695
try {
4686
- return new GZIPInputStream (input );
4696
+ // buffered has to go *around* the GZ, otherwise 25x slower
4697
+ return new BufferedInputStream (new GZIPInputStream (input ));
4687
4698
} catch (IOException e ) {
4688
- e . printStackTrace ();
4699
+ printStackTrace (e );
4689
4700
return null ;
4690
4701
}
4691
4702
}
4692
- return input ;
4703
+ return new BufferedInputStream ( input ) ;
4693
4704
}
4694
4705
4695
4706
@@ -4746,7 +4757,7 @@ public InputStream createInputRaw(String filename) {
4746
4757
4747
4758
} catch (IOException e ) {
4748
4759
// changed for 0117, shouldn't be throwing exception
4749
- e . printStackTrace ();
4760
+ printStackTrace (e );
4750
4761
//System.err.println("Error downloading from URL " + filename);
4751
4762
return null ;
4752
4763
//throw new RuntimeException("Error downloading from URL " + filename);
@@ -4880,9 +4891,9 @@ static public InputStream createInput(File file) {
4880
4891
try {
4881
4892
InputStream input = new FileInputStream (file );
4882
4893
if (file .getName ().toLowerCase ().endsWith (".gz" )) {
4883
- return new GZIPInputStream (input );
4894
+ return new BufferedInputStream ( new GZIPInputStream (input ) );
4884
4895
}
4885
- return input ;
4896
+ return new BufferedInputStream ( input ) ;
4886
4897
4887
4898
} catch (IOException e ) {
4888
4899
System .err .println ("Could not createInput() for " + file );
@@ -5067,7 +5078,7 @@ public OutputStream createOutput(String filename) {
5067
5078
return fos ;
5068
5079
5069
5080
} catch (IOException e ) {
5070
- e . printStackTrace ();
5081
+ printStackTrace (e );
5071
5082
}
5072
5083
return null ;
5073
5084
}
0 commit comments