public String read(int n){
        if(n < 0) return null;
        if(n == 0) return "";

        StringBuilder result = new StringBuilder();
        while(n > 0){
            if(buffer == null || p == buffer.length()){
                buffer = read4096();
                p = 0;
                if(buffer.length() == 0) break;
            }else{
                int numChars = buffer.length() - p;
                if(n <= numChars){
                    result.append(buffer.substring(p, p + n));
                    p += n;
                    n = 0;
                }else{
                    result.append(buffer.substring(p));
                    p = buffer.length();
                    n -= numChars;
                }
            }
        }
        return result.toString();
    }