Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.UnsupportedEncodingException;

import javax.mail.MessagingException;

import javax.mail.internet.MimeMessage;

import javax.mail.internet.MimeUtility;

public class Main {

    public static String getSubject(MimeMessage msg) throws UnsupportedEncodingException, MessagingException {
        return decodeText(msg.getSubject());
    }

    public static String decodeText(String encodeText) throws UnsupportedEncodingException {
        if (encodeText == null || "".equals(encodeText)) {
            return "";
        } else {
            encodeText = MimeUtility.decodeText(encodeText);
            return MimeUtility.decodeText(encodeText);
        }
    }
}