예제 #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
파일: LibRt.java 프로젝트: yamila87/rt_src
 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;
 }