Пример #1
0
 public int read() throws IOException {
   if (n > 0) return buf[--n];
   int c = r.read();
   if (c < 0x80) return c;
   n = 0;
   if (c < 0x800) {
     buf[n++] = (0x80 | (c & 0x3f));
     return (0xC0 | ((c >> 6) & 0x1f));
   } else {
     buf[n++] = (0x80 | (c & 0x3f));
     buf[n++] = (0x80 | ((c >> 6) & 0x3f));
     return (0xE0 | ((c >> 12) & 0x0f));
   }
 }
Пример #2
0
 public static String get_stream(Reader isr) throws IOException {
   char[] buffer = new char[BUFF_SZ];
   StringBuilder out = new StringBuilder();
   logm("DBG", 9, "STREAM GET", isr + "");
   for (; ; ) {
     int rsz = isr.read(buffer, 0, buffer.length);
     logm("DBG", 9, "STREAM GET READ", rsz);
     if (rsz < 0) break;
     out.append(buffer, 0, rsz);
   }
   String s = out.toString();
   logm("DBG", 9, "STREAM GET RESULT", s);
   return s;
 }