private Vector readlinesfromfile(String fname) { // trims lines and removes comments Vector v = new Vector(); try { BufferedReader br = new BufferedReader(new FileReader(new File(fname))); while (br.ready()) { String tmp = br.readLine(); // Strip comments while (tmp.indexOf("/*") >= 0) { int i = tmp.indexOf("/*"); v.add(tmp.substring(0, i)); String rest = tmp.substring(i + 2); while (tmp.indexOf("*/") == -1) { tmp = br.readLine(); } tmp = tmp.substring(tmp.indexOf("*/") + 2); } if (tmp.indexOf("//") >= 0) tmp = tmp.substring(0, tmp.indexOf("//")); // Strip spaces tmp = tmp.trim(); v.add(tmp); // System.out.println("Read line "+tmp); } br.close(); } catch (Exception e) { System.out.println("Exception " + e + " occured"); } return v; }
FileHash(File f) { hash=new long[(int)f.length()]; length=f.length(); int i=0; int h=0; try { BufferedReader br=new BufferedReader(new FileReader(f)); while (br.ready()) { int c=br.read(); h=h+c; hash[i]=h; } br.close(); } catch (Exception e) { System.out.println("What should I do with exception "+e+" ?"); } System.out.println(""+h); }