Session getProvider Example
Session class getProvider example. This example shows you how to use getProvider method.
Session class getProvider example. public Provider getProvider(String protocol) throws NoSuchProviderException Returns the default Provider for the protocol specified. Checks mail.protocol.class property first and if it exists, returns the Provider associated with this implementation. If it doesn't exist, returns the Provider that appeared first in the configuration files. If an implementation for the protocol isn't found, throws NoSuchProviderException
/*
* @ # GetProvider.java
* A class repersenting use to GetProvider method
* of Session class in javax.mail package
* version 07 July 2008
* author Rose India
*/
package session;
import java.util.*;
import javax.mail.*;
public class GetProvider {
public static void main(String args[]) throws Exception {
Properties properties = System.getProperties();
Session session = Session.getDefaultInstance(properties, null);
Provider provider = session.getProvider("pop3");
System.out.println("Protocol : " + provider.getProtocol());
System.out.println("Class Name : " + provider.getClassName());
System.out.println("Vendor : " + provider.getVendor());
System.out.println("Version : " + provider.getVersion());
}
} |
Output
Protocol : pop3
Class Name : com.sun.mail.pop3.POP3Store
Vendor : Sun Microsystems, Inc
Version : null |
|