@@ -6927,18 +6927,22 @@ static public PrintWriter createWriter(OutputStream output) {
69276927 */
69286928 public InputStream createInput(String filename) {
69296929 InputStream input = createInputRaw(filename);
6930- final String lower = filename.toLowerCase();
6931- if ((input != null) &&
6932- (lower.endsWith(".gz") || lower.endsWith(".svgz"))) {
6933- try {
6934- // buffered has to go *around* the GZ, otherwise 25x slower
6935- return new BufferedInputStream(new GZIPInputStream(input));
6936- } catch (IOException e) {
6937- printStackTrace(e);
6938- return null;
6930+ if (input != null) {
6931+ // if it's gzip-encoded, automatically decode
6932+ final String lower = filename.toLowerCase();
6933+ if (lower.endsWith(".gz") || lower.endsWith(".svgz")) {
6934+ try {
6935+ // buffered has to go *around* the GZ, otherwise 25x slower
6936+ return new BufferedInputStream(new GZIPInputStream(input));
6937+
6938+ } catch (IOException e) {
6939+ printStackTrace(e);
6940+ }
6941+ } else {
6942+ return new BufferedInputStream(input);
69396943 }
69406944 }
6941- return new BufferedInputStream(input) ;
6945+ return null ;
69426946 }
69436947
69446948
@@ -7109,9 +7113,14 @@ static public InputStream createInput(File file) {
71097113 if (file == null) {
71107114 throw new IllegalArgumentException("File passed to createInput() was null");
71117115 }
7116+ if (!file.exists()) {
7117+ System.err.println(file + " does not exist, createInput() will return null");
7118+ return null;
7119+ }
71127120 try {
71137121 InputStream input = new FileInputStream(file);
7114- if (file.getName().toLowerCase().endsWith(".gz")) {
7122+ final String lower = file.getName().toLowerCase();
7123+ if (lower.endsWith(".gz") || lower.endsWith(".svgz")) {
71157124 return new BufferedInputStream(new GZIPInputStream(input));
71167125 }
71177126 return new BufferedInputStream(input);
@@ -7247,6 +7256,11 @@ static public byte[] loadBytes(InputStream input) {
72477256 * @nowebref
72487257 */
72497258 static public byte[] loadBytes(File file) {
7259+ if (!file.exists()) {
7260+ System.err.println(file + " does not exist, loadBytes() will return null");
7261+ return null;
7262+ }
7263+
72507264 try {
72517265 InputStream input;
72527266 int length;
@@ -7295,6 +7309,11 @@ static public byte[] loadBytes(File file) {
72957309 * @nowebref
72967310 */
72977311 static public String[] loadStrings(File file) {
7312+ if (!file.exists()) {
7313+ System.err.println(file + " does not exist, loadStrings() will return null");
7314+ return null;
7315+ }
7316+
72987317 InputStream is = createInput(file);
72997318 if (is != null) {
73007319 String[] outgoing = loadStrings(is);
0 commit comments