I was looking at that `javamail` [faqs](http://www.oracle.com/technetwork/java/javamail/faq/index.html#mainbody), I was looking at this snippet which is supposed to extract the body of the email:

```
    private boolean textIsHtml = false;

    /**
     * Return the primary text content of the message.
     */
    private String getText(Part p) throws
                MessagingException, IOException {
        if (p.isMimeType("text/*")) {
            String s = (String)p.getContent();
            textIsHtml = p.isMimeType("text/html");
            return s;
        }

        if (p.isMimeType("multipart/alternative")) {
            // prefer html text over plain text
            Multipart mp = (Multipart)p.getContent();
            String text = null;
            for (int i = 0; i < mp.getCount(); i++) {
                Part bp = mp.getBodyPart(i);
                if (bp.isMimeType("text/plain")) {
                    if (text == null)
                        text = getText(bp);
                    continue;
                } else if (bp.isMimeType("text/html")) {
                    String s = getText(bp);
                    if (s != null)
                        return s;
                } else {
                    return getText(bp);
                }
            }
            return text;
        } else if (p.isMimeType("multipart/*")) {
            Multipart mp = (Multipart)p.getContent();
            for (int i = 0; i < mp.getCount(); i++) {
                String s = getText(mp.getBodyPart(i));
                if (s != null)
                    return s;
            }
        }

        return null;
    }

```

Now the code can be refactored to the following version which is basically less lines of code: 

```
    private static String getText(Part message) {
        String text = null;

        try {
            if (message.isMimeType("text/*")) {
                text = (String) message.getContent();
            }

            if (message.isMimeType("multipart/alternative") || message.isMimeType("multipart/*")) {
                Multipart multiPart = (Multipart) message.getContent();
                Part bodyPart       = multiPart.getBodyPart(multiPart.getCount() - 1);
                text                = getText(bodyPart);
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
        }

        return text;
    }

```

My question is, why the old code looping through the parts for both `multipart/alternative` and `multipart/*` messages? Am I missing something here? 

Update:

Just saw Jon's comment, I have a further question, is there any scenario where my version of the code will break?