skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

  • Home
 
  • RSS
  • Twitter
Showing posts with label Java Mail Examples. Show all posts
Showing posts with label Java Mail Examples. Show all posts
Thursday, October 25, 2012

Send outlook meeting request using Java Mail API

Posted by Raju Gupta at 2:45 AM – 1 comments
 
This Program is useful to send meeting request to the users using Java mail API.We need to include mail.jar in the classpath.

import java.util.Properties;
import javax.activation.DataHandler;
import javax.mail.BodyPart; 
import javax.mail.Message; 
import javax.mail.MessagingException;
import javax.mail.Multipart; 
import javax.mail.Session; 
import javax.mail.Transport; 
import javax.mail.internet.InternetAddress; 
import javax.mail.internet.MimeBodyPart; 
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart; 
import javax.mail.util.ByteArrayDataSource; 
public class Email {

 public void send() throws Exception { 
  try {
   String host = "abc.com";//hostname of the mail server
   String from = "xx.xx.com"; //from internet address
   String to = "xx.xx.com"; //to internet address
   Properties prop = new Properties(); 
   prop.put("mail.host", host);   
   Session session = Session.getDefaultInstance(prop, null); 
   // Define message 
   MimeMessage message = new MimeMessage(session);
   message.addHeaderLine("method=REQUEST");
   message.addHeaderLine("charset=UTF-8"); 
   message.addHeaderLine("component=VEVENT"); 
   message.setFrom(new InternetAddress(from)); 
   message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); 
   message.setSubject("Meeting Request Using JavaMail"); 
   StringBuffer sb = new StringBuffer();  
   StringBuffer buffer = sb.append("BEGIN:VCALENDARn"+
     "PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//ENn"+
     "VERSION:2.0n" +
     "METHOD:REQUESTn" + 
     "BEGIN:VEVENTn" +
     "ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:xx.xx.comn" + 
     "ORGANIZER:MAILTO:xx.xx.comn" + 
     "DTSTART:20120703T134500Zn" + 
     "DTEND:20120703T140000Zn" + 
     "LOCATION:3N1 Conference roomn" +
     "TRANSP:OPAQUEn" +
     "SEQUENCE:0n" +
     "UID:040000008200E00074C5B7101A82E00800000000002FF466CE3AC5010000000000000000100n" +
     " 000004377FE5C37984842BF9440448399EB02n" +
     "DTSTAMP:20120703T120102Zn" + 
     "CATEGORIES:Meetingn" +
     "DESCRIPTION:This is a test meeting request.checking using JAVA .Please ingore itnn" +
     "SUMMARY:Test meeting requestn" + 
     "PRIORITY:1n" +
     "CLASS:PUBLICn" + 
     "BEGIN:VALARMn" + 
     "TRIGGER:PT1440Mn" +
     "ACTION:DISPLAYn" + 
     "DESCRIPTION:Remindern" +
     "END:VALARMn" +
     "END:VEVENTn" +
   "END:VCALENDAR");  // Create the message part
   BodyPart messageBodyPart = new MimeBodyPart(); 
   // Fill the message  
   messageBodyPart.setHeader("Content-Class", "urn:content-classes:calendarmessage");
   messageBodyPart.setHeader("Content-ID","calendar_message"); 
   messageBodyPart.setDataHandler(new DataHandler( new ByteArrayDataSource(buffer.toString(), "text/calendar")));//very important
   // Create a Multipart  
   Multipart multipart = new MimeMultipart();  
   // Add part one 
   multipart.addBodyPart(messageBodyPart);    
   // Put parts in message
   message.setContent(multipart);  
   // send message 
   Transport.send(message);
  } catch (MessagingException me) {
   me.printStackTrace(); 
  } catch (Exception ex) {
   ex.printStackTrace(); 
  } 
 } 


 /* @param args */ 
 public static void main(String[] args) { 
  try {
   Email email = new Email(); 
   email.send();
   System.out.println("meeting request is sent");
  } catch (Exception e) {
   e.printStackTrace(); 
  }  
 } 
}

[ Read More ]
Read more...
Monday, October 22, 2012

Send a mail from SMTP server using Java Mail

Posted by Raju Gupta at 1:55 AM – 0 comments
 
This code allows the user to login to his/her mail account to send a mail to another recepient.First the code needs to be configured by entering the Server details and user credentials .This code authenticates the user and creates a session then a MimeMessage Object is created where the subject and content of the mail is set.

public class SmtpMail{
 public static void main(String[] args) 
 {
  Properties props = new Properties();
  props.put("mail.smtp.auth", "true");
  props.put("mail.smtp.starttls.enable", "true");
  props.put("mail.smtp.host", "smtp.gmail.com");
  props.put("mail.smtp.port", "587");
  final String username = "Username@gmail.com";
  final String password = "Password";
  Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
 protected PasswordAuthentication getPasswordAuthentication() {
   return new PasswordAuthentication(username, password);
  }
  });
try {
   Message message = new MimeMessage(session);
   message.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse("toEmailAddress@yahoo.com"));
   System.out.println(session.toString());
   message.setSubject("JavaMail Subject");
   message.setText("Dear Recepient,"
    + "\n\n This is a Test Mail");
   System.out.println(session.toString());
   Transport.send(message);
   System.out.println("Done");
 
  } catch (MessagingException e) {
   throw new RuntimeException(e);
  }
 }
}


[ Read More ]
Read more...
Saturday, October 13, 2012

This code can be used in any java application to send mails

Posted by Raju Gupta at 12:00 PM – 0 comments
 

Attached jar file (EmailSender v1.0) can be used in any Java/J2EE application to send authenticated as well as non authenticated mails. Jar supporting only 4 free smtp hosts.
1. Gmail (smtp.gmail.com)
2. Yahoo (smtp.mail.yahoo.com)
3. Rediff (smtp.rediffmail.com)
4. HotMail (smtp.live.com)
This jar file can be used as a stand alone application or can be integrated with any J2EE application.

import java.io.BufferedReader;   
import java.io.File;   
import java.io.IOException;   
import java.io.InputStreamReader;   
import java.io.RandomAccessFile;   
import java.util.ArrayList;   
import java.util.Date;   
import java.util.Properties;   
import java.util.StringTokenizer;   
  
import javax.activation.DataHandler;   
import javax.activation.DataSource;   
import javax.activation.FileDataSource;   
import javax.mail.Address;   
import javax.mail.Authenticator;   
import javax.mail.Message;   
import javax.mail.MessagingException;   
import javax.mail.Multipart;   
import javax.mail.PasswordAuthentication;   
import javax.mail.SendFailedException;   
import javax.mail.Session;   
import javax.mail.Transport;   
import javax.mail.internet.InternetAddress;   
import javax.mail.internet.MimeBodyPart;   
import javax.mail.internet.MimeMessage;   
import javax.mail.internet.MimeMultipart;   
import javax.mail.util.ByteArrayDataSource;   
  
public class EmailManager   
{   
    private String AUTH_USER_NAME;   
    private String AUTH_PWD;   
    private String SMTP_HOST;   
    private String SMTP_PORT;   
  
           
    public void sendEmailWithAuthentication(String filePath, String strFromEmailId, String strToEmailId, String strEmailSubject, String fileAttachment) throws Exception   
    {   
        StringBuilder strFileText = new StringBuilder("");   
  
        try  
        {   
  
            try  
            {   
                if(filePath != null)   
                {   
                    File textFile = new File(filePath);   
                    RandomAccessFile rendFile = new RandomAccessFile(textFile, "r");   
       
                    while (rendFile.getFilePointer() < rendFile.length())   
                    {   
                        strFileText.append("\n").append(rendFile.readLine());   
                    }   
                }   
            }   
            catch (Exception e)   
            {   
                System.err.println("Could not find file: " + e);   
                e.printStackTrace();   
            }   
  
            boolean debug = Boolean.valueOf("true").booleanValue();   
  
            Properties props = new Properties();   
            props.put("mail.smtp.host", SMTP_HOST);   
            props.put("mail.smtp.auth", "true");   
            props.put("mail.debug", "true");   
            props.put("mail.smtp.port", SMTP_PORT);   
            props.put("mail.smtp.starttls.enable","true");   
            props.put("mail.smtp.socketFactory.port", SMTP_PORT);    
            props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");    
            props.put("mail.smtp.socketFactory.fallback", "false");    
  
            Authenticator auth = new SMTPAuthenticator();//Added 4 authentication   
               
            Session session = Session.getDefaultInstance(props, auth);   
            session.setDebug(debug);   
  
            Message msg = new MimeMessage(session);   
  
            msg.setDataHandler(new DataHandler(new ByteArrayDataSource(strFileText.toString(), "text/plain")));   
            msg.setFrom(new InternetAddress(strFromEmailId));   
  
            // create the message part    
            if(fileAttachment != null)   
            {   
                MimeBodyPart messageBodyPart = new MimeBodyPart();   
                messageBodyPart.setText(strFileText.toString());   
                   
                Multipart multipart = new MimeMultipart();   
                multipart.addBodyPart(messageBodyPart);   
                messageBodyPart = new MimeBodyPart();   
                DataSource source = new FileDataSource(fileAttachment);   
                messageBodyPart.setDataHandler(new DataHandler(source));   
                messageBodyPart.setFileName(fileAttachment);   
                multipart.addBodyPart(messageBodyPart);   
                msg.setContent(multipart);   
            }   
               
               
            StringTokenizer strtok = new StringTokenizer(strToEmailId, ",");   
            String subStrToEmailId[] = new String[strtok.countTokens()];   
            int countToMail = 0;   
            while (strtok.hasMoreTokens())   
            {   
                subStrToEmailId[countToMail] = strtok.nextElement().toString().trim();   
                countToMail++;   
            }   
  
            for (int i = 0; i < subStrToEmailId.length; i++)   
            {   
  
                InternetAddress[] address = { new InternetAddress(subStrToEmailId[i]) };   
                msg.addRecipients(Message.RecipientType.TO, address);   
            }   
  
            msg.setSubject(strEmailSubject);   
            Date dt = new Date();   
            msg.setSentDate(dt);   
            System.out.println("Before sending message... ");   
            Transport.send(msg);   
            System.out.println("After sending message... ");   
        }   
        catch (MessagingException mex)   
        {   
            System.out.println("\n--Exception handling in msgsendsample.java");   
  
            mex.printStackTrace();   
            System.out.println();   
            Exception ex = mex;   
            do  
            {   
                if (ex instanceof SendFailedException)   
                {   
                    SendFailedException sfex = (SendFailedException) ex;   
                    Address[] invalid = sfex.getInvalidAddresses();   
                    if (invalid != null)   
                    {   
                        System.out.println("    ** Invalid Addresses");   
                        if (invalid != null)   
                        {   
                            for (int i = 0; i < invalid.length; i++)   
                                System.out.println("         " + invalid[i]);   
                        }   
                    }   
                    Address[] validUnsent = sfex.getValidUnsentAddresses();   
                    if (validUnsent != null)   
                    {   
                        System.out.println("    ** ValidUnsent Addresses");   
                        if (validUnsent != null)   
                        {   
                            for (int i = 0; i < validUnsent.length; i++)   
                                System.out.println("         " + validUnsent[i]);   
                        }   
                    }   
                    Address[] validSent = sfex.getValidSentAddresses();   
                    if (validSent != null)   
                    {   
                        System.out.println("    ** ValidSent Addresses");   
                        if (validSent != null)   
                        {   
                            for (int i = 0; i < validSent.length; i++)   
                                System.out.println("         " + validSent[i]);   
                        }   
                    }   
                }   
                System.out.println();   
                if (ex instanceof MessagingException)   
                    ex = ((MessagingException) ex).getNextException();   
                else  
                    ex = null;   
            }   
            while (ex != null);   
        }   
  
        catch (Exception e)   
        {   
            System.err.println("Error Message: " + e.getMessage());   
        }   
    }   
       
       
       
    private class SMTPAuthenticator extends Authenticator {   
        public PasswordAuthentication getPasswordAuthentication() {   
           String username = AUTH_USER_NAME;   
           String password = AUTH_PWD;   
           return new PasswordAuthentication(username, password);   
        }   
    }   
}  


[ Read More ]
Read more...

Sending mail to gmail account using Java

Posted by Raju Gupta at 2:00 AM – 0 comments
 
This code helps us to send mail to the gmail account using java code.

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
 
public class SendMailTest {
 
 public static void main(String[] args) throws AddressException, MessagingException {
 
  String host = "smtp.gmail.com";        
  String from = "username";        
  String pass = "password";        
  Properties props = System.getProperties();   
  props.setProperty("proxySet","true");
  props.setProperty("http.proxyHost","192.168.155.1");
  props.setProperty("http.proxyPort","808");
  props.put("mail.smtp.starttls.enable", "true");    
  // added this line  
  props.put("mail.smtp.host", host);       
  props.put("mail.smtp.user", from);        
  props.put("mail.smtp.password", pass);        
  props.put("mail.smtp.port", "587");        
  props.put("mail.smtp.auth", "true");          
  String[] to = {"to@gmail.com"};    
  // added this line          
    
  Session session = Session.getDefaultInstance(props, null);        
  MimeMessage message = new MimeMessage(session);        
  message.setFrom(new InternetAddress(from));          
  InternetAddress[] toAddress = new InternetAddress[to.length];    
  // To get the array of addresses        
  for( int i=0; i < to.length; i++ )    
  {    
  // changed from a while loop            
  toAddress[i] = new InternetAddress(to[i]);        
  }        
  System.out.println(Message.RecipientType.TO);   
    
  for(    
  int i=0; i < toAddress.length; i++)    
  {    
  // changed from a while loop            
  message.addRecipient(Message.RecipientType.TO, toAddress[i]);   
  }        
  message.setSubject("sending in a group");        
  message.setText("Welcome to JavaMail");        
  Transport transport = session.getTransport("smtp");        
  transport.connect(host, from, pass);        
  transport.sendMessage(message, message.getAllRecipients());        
  transport.close();   
 }
} 


[ Read More ]
Read more...
Older Posts
Subscribe to: Posts ( Atom )

List of Java Programs

  • Java Program to check Greater between the Two Number
  • Java Program to find that given number is Palindrome or not
  • Java Program to Demonstrate the Use of Pre and Post Operator
  • Java Program to Reverse the Given Number
  • Java Program to Print Number in the Given Data Type
  • Program to Demonstrate Skipping using Continue
  • Program to find whether entered character is a vowel or Consonant
  • Java Program to Calculate the Sum of Digits of Given Number
  • How to swap two numbers using only two variables
  • Checking the Given Number is Armstrong or Not
  • Average an Array of Values
  • Display ASCII Code Instead of Character
  • Comparison of Two Variable using If
  • Printing Table In java using While Loop
  • Generate Random Number Using Math.Random Function
  • To Find roots of Quadratic Equation
  • Performing Arithmetic Opration on Two Variable
  • Concatenation of Two String in Java
  • Command Line Argument in JAVA
  • Java Hello World Program
  • Calculate Circle Perimeter | Java Program
  • Calculate the Area of Circle | Java Program
  • To Find Whether Given Year is a Leap Year or not
  • Popular
  • Recent
  • Archives

Total Pageviews

Sparkline

Followers

Popular Posts of This Week

  • To Sort an Interger Array using Shell Sort
    To Sort an Interger Array using Shell Sort class ShellSort { public static int[] shellSort(int[] array) { int N = array.length; ...
  • Power of Java Reflection API
     Reflection API is part of core java. This is the most powerful API that java has ever  produced. Reflection is the powerful technique a...
  • Count the PDF Pages using Java
    To get number of pages in the PDF import java.io.*; import com.lowagie.text.pdf.PdfReader; public class PDFSize { //static String P...
  • Send outlook meeting request using Java Mail API
    This Program is useful to send meeting request to the users using Java mail API.We need to include mail.jar in the classpath. import ja...
  • Barcodes Encoding Decoding Java Example
    General Overview of BarCodes and using them to encode and decode BitMatrix bitMatrix = null;// initialize bitMatrix = new PDF417Writer()....
  • Singly linked list with header - Data Structure
    class OrderedList { private int value; private OrderedList next; // Note: No setValue() method or setNext() methods are provide...
  • Implementation of a basic generic tree, with labels of type T - Data Structure
    // This implements a basic generic tree, with labels of type T, // pointer to the parent node, and a singly linked list of children nodes...
  • Craeting Thumnails from images
    This code sniipet will tell us how to create thumbnails from images through java code private void createThumbnail(String filename, i...
  • Java Program to Print Number in the Given Data Type
    Here is Java Program to print number given in the data types public class second{ public static void main(String[] args){ int n; ...
  • Create an application with a square window Using Swing Part 2
     Add six buttons to the application in the Following example in a vertical column on the left side of the application window. Create an a...
Powered by Blogger.

Archives

  • ▼  2014 ( 4 )
    • ▼  August ( 4 )
      • Java program to create a Binary Heap and Perform v...
      • Create an Adjacency matrix Graph and perform Add a...
      • To Sort an Interger Array using Shell Sort
      • Sort an Integer array with Bucket Sort
  • ►  2013 ( 6 )
    • ►  August ( 1 )
    • ►  April ( 5 )
  • ►  2012 ( 673 )
    • ►  November ( 9 )
    • ►  October ( 223 )
    • ►  September ( 272 )
    • ►  August ( 2 )
    • ►  June ( 1 )
    • ►  February ( 67 )
    • ►  January ( 99 )
 

Our Blogs

  • Linux Tutorial
  • C Programming Tutorial

Labels

  • Agile Methodology ( 1 )
  • Algorithm ( 3 )
  • AntiSamy ( 1 )
  • Arithmetic Operation ( 1 )
  • Array Example ( 9 )
  • ArrayList Examples ( 11 )
  • Average an Array of Values ( 1 )
  • Barcode Example ( 1 )
  • Basic Java Programs ( 34 )
  • Bing API Example ( 2 )
  • BitSet Example ( 1 )
  • Boolean Example ( 1 )
  • Bouncy Castle API ( 1 )
  • Break Statement ( 2 )
  • BufferedReader Example ( 2 )
  • Calendar Example ( 1 )
  • Chart Generation Example ( 1 )
  • Command Line Argument ( 1 )
  • Comparator Example ( 1 )
  • Concatenation of String ( 1 )
  • Continue Statement ( 1 )
  • Control Structure ( 1 )
  • Copy File Example ( 1 )
  • CRC Example ( 1 )
  • CSV Example ( 6 )
  • Data Structure ( 5 )
  • Date Example ( 2 )
  • Directory Example ( 1 )
  • Do - While Loop Example ( 1 )
  • Domino Database ( 1 )
  • Email Example ( 8 )
  • Encryption Example ( 3 )
  • Excel Example ( 15 )
  • Factorial Example ( 1 )
  • File Upload Example ( 1 )
  • Find Roots of Quadratic Equation ( 1 )
  • FTP Example ( 2 )
  • Graph Examples ( 1 )
  • Greater between Two Numbers ( 1 )
  • GSON Library ( 1 )
  • HashMap Example ( 1 )
  • HashSet Example ( 1 )
  • Hello World Program ( 1 )
  • If Condition ( 2 )
  • Inner Class Example ( 1 )
  • iText Example ( 3 )
  • JAR File ( 1 )
  • JAVA Applet ( 1 )
  • Java Applications ( 1 )
  • Java AWT Example ( 9 )
  • Java Certification ( 1 )
  • Java Class Examples ( 15 )
  • Java Collection Example ( 1 )
  • Java Command Example ( 4 )
  • Java Constructor Examples ( 1 )
  • Java Currency Example ( 1 )
  • Java Database Example ( 3 )
  • Java Date and Time Example ( 3 )
  • Java DateFormat Example ( 3 )
  • Java Examples ( 2 )
  • Java Exception Example ( 5 )
  • Java File Example ( 22 )
  • Java GUI Example ( 1 )
  • Java Image Examle ( 3 )
  • Java Inheritance Example ( 3 )
  • Java Input Output Example ( 1 )
  • Java IO Example ( 3 )
  • Java Jar Example ( 1 )
  • Java JSON Example ( 3 )
  • Java Mail Examples ( 4 )
  • Java Map Example ( 5 )
  • Java MapReduce Example ( 2 )
  • Java MultiThreading Example ( 7 )
  • Java Network Example ( 9 )
  • Java Package ( 1 )
  • Java Programs ( 1 )
  • Java RMI ( 1 )
  • Java Robot Class Examples ( 2 )
  • Java Runtime Example ( 1 )
  • Java Swing Example ( 9 )
  • Java Util Example ( 1 )
  • Java Vector Example ( 4 )
  • Java Voice Example ( 1 )
  • Java Webservice Example ( 1 )
  • Java XML Example ( 3 )
  • Java Zip Class Examples ( 2 )
  • JDBC ( 9 )
  • JDK Version Comparison ( 1 )
  • JFrame Example ( 3 )
  • JOptionPane Dialog Example ( 1 )
  • JPanel Example ( 1 )
  • JSP Example ( 2 )
  • JSTL Example ( 1 )
  • jUnit Example ( 2 )
  • LinkedList Example ( 2 )
  • List Example ( 1 )
  • Long Variable ( 1 )
  • Lottery Nubmer ( 1 )
  • MD5 Hashing Example ( 3 )
  • Memory Management Example ( 1 )
  • Method Override ( 1 )
  • MIDI Sound ( 8 )
  • Module Operator Example ( 2 )
  • Multiplication Table ( 1 )
  • Observer Interface Example ( 1 )
  • Operator Example ( 5 )
  • Pagination ( 1 )
  • Palindrome Number ( 1 )
  • Pass By Reference Example ( 1 )
  • Pass By Value Example ( 1 )
  • PDF File Example ( 3 )
  • PDF Generation Example ( 4 )
  • Pre and Post Operator ( 2 )
  • Prime Number ( 3 )
  • Progress Bar Example ( 1 )
  • Property List Example ( 2 )
  • Random Function ( 7 )
  • Recursion Example ( 2 )
  • Regex Example ( 2 )
  • Remote Host Example ( 2 )
  • Robot Class ( 4 )
  • Searching Example ( 3 )
  • Slideshow ( 1 )
  • Sorting Example ( 7 )
  • SpringLayout Example ( 1 )
  • Stack Example ( 4 )
  • Static Variable ( 1 )
  • StreamTokenizer Example ( 2 )
  • String Example ( 19 )
  • Struts2 Example ( 1 )
  • Sum of Digits ( 1 )
  • Swap Two Numbers ( 1 )
  • Switch Case ( 3 )
  • Tapestry Components ( 1 )
  • Thumbnail Example ( 2 )
  • TimerTask Example ( 2 )
  • To Calculate Volume ( 1 )
  • To Check Armstrong Number ( 1 )
  • Tree Example ( 1 )
  • TreeMap Example ( 1 )
  • TreeSet Example ( 1 )
  • Two Dimensional Array Example ( 1 )
  • UUID ( 1 )
  • Validation Example ( 2 )
  • Variable Casting ( 1 )
  • While Loop ( 1 )
  • XML Parsing ( 7 )
  • XSS Attacks ( 1 )
  • Zip File ( 15 )

Popular Posts

  • Creating Dynamic Macro Enabled Excel by Java
    We can create a dynamic macro enabled excel by java: We need to create a excel sheet template with macro on server. we can copy the...
  • Java program to create a Binary Heap and Perform various operation
    A binary heap (min-heap) is a complete binary tree with elements from a partially ordered set, such that the element at every node is less ...
  • To Sort an Interger Array using Shell Sort
    To Sort an Interger Array using Shell Sort class ShellSort { public static int[] shellSort(int[] array) { int N = array.length; ...
  • Implementation of a basic generic tree, with labels of type T - Data Structure
    // This implements a basic generic tree, with labels of type T, // pointer to the parent node, and a singly linked list of children nodes...
  • Create an Adjacency matrix Graph and perform Add and Remove operation
    import java.util.ArrayList; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; import...
  • Printing Table In java using While Loop
    Here is a Java Program to Print the Table public class Table { public static void main(String[] args) { int no = Integer.p...
  • Merge-Sort Algorithm implementation in JAVA
    Merge-Sort Function void MergeSort(int low, int high) // a[low : high] is a global array to be sorted. // Small(P) is true if there...
  • Sort an Integer array with Bucket Sort
    Here is a java program to Sort an Integer array with Bucket Sort class BucketSort { public int[] bucketSort(int[] array) { /...
  • Stack implemented as array - Data Structure
    // Stack implemented as array public class ArrayStack<T> { private T[] stack; private int numElements = 0; // points to s...
  • Java Program to Generate the Lottery Number between 1 to 49
     A lottery requires that you select six different numbers from the integers 1 to 49. Write a program to do this for you and generate five s...
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger