5/25/2015

Code read file text

 // doc file text
    public String readFile(int path) throws IOException {
        String str="";
        StringBuffer buf = new StringBuffer();
        InputStream is = this.getResources().openRawResource(path);
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader reader = new BufferedReader(isr);
        if(is!=null){
            while ((str=reader.readLine())!=null){
                buf.append(str+"\n");
            }
            str = String.valueOf(buf);
        }
        is.close();
        return str;
    }

No comments:

Post a Comment