private int readServerResponse() throws IOException {
  StringBuffer replyBuf=new StringBuffer(32);
  int c;
  int continuingCode=-1;
  int code;
  String response;
  serverResponse.setSize(0);
  while (true) {
    while ((c=in.read()) != -1) {
      if (c == '\r') {
        if ((c=in.read()) != '\n') {
          replyBuf.append('\r');
        }
      }
      replyBuf.append((char)c);
      if (c == '\n') {
        break;
      }
    }
    response=replyBuf.toString();
    replyBuf.setLength(0);
    if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
      logger.finest("Server [" + serverAddr + "] --> "+ response);
    }
    if (response.length() == 0) {
      code=-1;
    }
 else {
      try {
        code=Integer.parseInt(response.substring(0,3));
      }
 catch (      NumberFormatException e) {
        code=-1;
      }
catch (      StringIndexOutOfBoundsException e) {
        continue;
      }
    }
    serverResponse.addElement(response);
    if (continuingCode != -1) {
      if (code != continuingCode || (response.length() >= 4 && response.charAt(3) == '-')) {
        continue;
      }
 else {
        continuingCode=-1;
        break;
      }
    }
 else     if (response.length() >= 4 && response.charAt(3) == '-') {
      continuingCode=code;
      continue;
    }
 else {
      break;
    }
  }
  return code;
}

private int readServerResponse ( ) throws IOException { StringBuffer replyBuf = new StringBuffer ( 32 ) ; int c ; int continuingCode = - 1 ; int code ; String response ; serverResponse . setSize ( 0 ) ; while ( true ) { while ( ( c = in . read ( ) ) != - 1 ) { if ( c == '\r' ) { if ( ( c = in . read ( ) ) != '\n' ) { replyBuf . append ( '\r' ) ; } } replyBuf . append ( ( char ) c ) ; if ( c == '\n' ) { break ; } } response = replyBuf . toString ( ) ; replyBuf . setLength ( 0 ) ; if ( logger . isLoggable ( PlatformLogger . Level . FINEST ) ) { logger . finest ( "Server [" + serverAddr + "] --> " + response ) ; } if ( response . length ( ) == 0 ) { code = - 1 ; } else { try { code = Integer . parseInt ( response . substring ( 0 , 3 ) ) ; } catch ( NumberFormatException e ) { code = - 1 ; } catch ( StringIndexOutOfBoundsException e ) { continue ; } } serverResponse . addElement ( response ) ; if ( continuingCode != - 1 ) { if ( code != continuingCode || ( response . length ( ) >= 4 && response . charAt ( 3 ) == '-' ) ) { continue ; } else { continuingCode = - 1 ; break ; } } else if ( response . length ( ) >= 4 && response . charAt ( 3 ) == '-' ) { continuingCode = code ; continue ; } else { break ; } } return code ; }
pulls the response from the server and returns the code as a number . returns - 1 on failure .
