private void closeIO() {
   try {
     mIn.close();
   } catch (Exception e) {
     /*
      * May fail if the connection is already closed.
      */
   }
   try {
     mOut.close();
   } catch (Exception e) {
     /*
      * May fail if the connection is already closed.
      */
   }
   try {
     mSocket.close();
   } catch (Exception e) {
     /*
      * May fail if the connection is already closed.
      */
   }
   mIn = null;
   mOut = null;
   mSocket = null;
 }
Exemplo n.º 2
0
 public void preamble(InputStream is) throws IOException {
   expect(MimeMultipart.class);
   StringBuffer sb = new StringBuffer();
   int b;
   while ((b = is.read()) != -1) {
     sb.append((char) b);
   }
   ((MimeMultipart) stack.peek()).setPreamble(sb.toString());
 }
    @Override
    public int read() throws IOException {
      if (mFinished) {
        return -1;
      }
      int d = mIn.read();
      if (mStartOfLine && d == '.') {
        d = mIn.read();
        if (d == '\r') {
          mFinished = true;
          mIn.read();
          return -1;
        }
      }

      mStartOfLine = (d == '\n');

      return d;
    }
 private String readLine() throws IOException {
   StringBuilder sb = new StringBuilder();
   int d = mIn.read();
   if (d == -1) {
     throw new IOException("End of stream reached while trying to read line.");
   }
   do {
     if (((char) d) == '\r') {
       continue;
     } else if (((char) d) == '\n') {
       break;
     } else {
       sb.append((char) d);
     }
   } while ((d = mIn.read()) != -1);
   String ret = sb.toString();
   if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
     Log.d(LOG_TAG, "<<< " + ret);
   }
   return ret;
 }