I am developing an app in eclipse ide
I want to read a text file which is in res folder line by line and initialise a HashTable whenever the app starts
All the file handing codes I found read char by char
Kindly help
Code:private String file(){ InputStream is = getClass().getResourceAsStream("/database.txt"); StringBuffer sb = new StringBuffer(); try{ int chars, i = 0; while ((chars = is.read()) != -1){ sb.append((char) chars); } return sb.toString(); }catch (Exception e){} return null; }

Reply With Quote

