private static double readDouble(PushbackReader read) throws IOException {
   StringBuffer s = new StringBuffer();
   int count = -1;
   while (true) {
     char ch = (char) read.read();
     // skip spaces
     if (ch == ' ') continue;
     count++;
     // allow a - only if at the beginning
     if (ch == '-' && count == 0) {
       // u.p("negative number");
       s.append(ch);
       continue;
     }
     if ((ch >= '0' && ch <= '9') || ch == '.') {
       // u.p("got double part " + ch);
       s.append(ch);
     } else {
       if (ch != ',') {
         read.unread(ch);
       }
       break;
     }
   }
   return Double.parseDouble(s.toString());
 }