Session getInstance Example

Session class getInstance example. This example shows you how to use getInstance method.


Session class getInstance example. public String getProperty(String name) Returns the value of the specified property. Returns null if this property does not exist.

Here is the code
/*
 * @ # GetInstance1
.java
 * A class repersenting use to
getInstance method 
 * of Session class in javax.mail package
 * version 05 July 2008
 * author Rose India 
 */
package session;

import java.util.*;
import javax.mail.*;

public class GetInstance1 {

    public static void main(String args[]) throws Exception {

        Properties properties = System.getProperties();

        Authenticator authenticator = new Authenticator() {

            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("username""password");
            }
        };

        Session session = Session.getDefaultInstance(properties, authenticator);
        System.out.println("Debug setting for this Session. " + session.getDebug());
    }
}

Output
Debug setting for this Session. false

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US