Escay

Reading from a file

    public String readFile(String filename){
        StringBuffer buffer = null;
        int ch;
        InputStream is = null;

        try {
            is = getClass().getResourceAsStream(filename);

            buffer = new StringBuffer();

            if (is != null) {
                while ((ch = is.read()) != -1) {
                    buffer.append((char) ch);
                }
                is.close();
            } else {
                System.out.println("File Does Not Exist");
            }
        } catch (java.io.IOException ex) {
            System.out.println(ex);
        }
        return buffer.toString();
    }

Reading from a unicode file

    public String readUnicodeFile(String filename) {
        StringBuffer buffer = null;
        InputStream is = null;
        InputStreamReader isr = null;

        try {
            Class c = this.getClass();
            is = c.getResourceAsStream(filename);

            if (is == null) {
                throw new Exception("File Does Not Exist");
            }
            isr = new InputStreamReader(is, "UTF8");

            buffer = new StringBuffer();
            int ch;

            while ((ch = isr.read()) > -1) {
                buffer.append((char) ch);
            }

            if (isr != null) {
                isr.close();
            }
        } catch (Exception ex) {
            System.out.println(ex);
        }
        return buffer.toString();
    }