static public String[] loadStrings(File file, String _enc) { InputStream is = openStream(file); if (is != null) return loadStrings(is, _enc); return null; } public String[] loadStrings(String filename, String _enc) { InputStream is = openStream(filename); if (is != null) return loadStrings(is,_enc); System.err.println("The file \"" + filename + "\" " + "is missing or inaccessible, make sure " + "the URL is valid or that the file has been " + "added to your sketch and is readable."); return null; } static public String[] loadStrings(InputStream input, String _enc) { try { BufferedReader reader = new BufferedReader(new InputStreamReader(input, _enc)); String lines[] = new String[100]; int lineCount = 0; String line = null; while ((line = reader.readLine()) != null) { if (lineCount == lines.length) { String temp[] = new String[lineCount << 1]; System.arraycopy(lines, 0, temp, 0, lineCount); lines = temp; } lines[lineCount++] = line; } reader.close(); if (lineCount == lines.length) { return lines; } // resize array to appropriate amount for these lines String output[] = new String[lineCount]; System.arraycopy(lines, 0, output, 0, lineCount); return output; } catch (IOException e) { e.printStackTrace(); //throw new RuntimeException("Error inside loadStrings()"); } return null; }