/** Returns a text file contained in ij.jar. */ public String openFromIJJar(String path) { String text = null; try { InputStream is = this.getClass().getResourceAsStream(path); // IJ.log(is+" "+path); if (is == null) return null; InputStreamReader isr = new InputStreamReader(is); StringBuffer sb = new StringBuffer(); char[] b = new char[8192]; int n; while ((n = isr.read(b)) > 0) sb.append(b, 0, n); text = sb.toString(); } catch (IOException e) { } return text; }
String open(String path) { if (path == null) return null; try { StringBuffer sb = new StringBuffer(5000); BufferedReader r = new BufferedReader(new FileReader(path)); while (true) { String s = r.readLine(); if (s == null) break; else sb.append(s + "\n"); } r.close(); return new String(sb); } catch (Exception e) { IJ.error(e.getMessage()); return null; } }