Example #1
0
  public static char[] readData(BufferedReader in) throws IOException {
    char[] c1 = new char[PACKET_SIZE];
    int i;
    int c_temp = in.read(); // c_temp is an int and not a char;
    if (c_temp != -1) {
      c1[0] = (char) c_temp;
    }

    for (i = 1; i < PACKET_SIZE && c_temp != -1; i++) {
      c_temp = in.read();
      c1[i] = (char) c_temp;
    }
    return c1;
  }
Example #2
0
 public String readword() throws IOException {
   StringBuilder b = new StringBuilder();
   int c;
   c = in.read();
   while (c >= 0 && c <= ' ') {
     c = in.read();
   }
   if (c < 0) {
     return "";
   }
   while (c > ' ') {
     b.append((char) c);
     c = in.read();
   }
   return b.toString();
 }