Breaking News
Home / Java / Java Snippets (page 4)

Java Snippets

How does SMTP debug looks like on sending email?

mymac:bin mv$ ./ com.infuzee.service.test.EmailerTest DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]DEBUG SMTP: useEhlo true, useAuth true DEBUG: SMTPTransport trying to connect to host “”, port 25 DEBUG SMTP RCVD: 220 ESMTP DEBUG: SMTPTransport connected to host “”, port: 25 DEBUG SMTP SENT: EHLO mymac.localDEBUG SMTP RCVD: LOGIN PLAIN250-8BITMIME250 PIPELINING …

Read More »

How to cleanup Quartz Jobs on shutdown in Java?

/** * Shutdown the scheduler  */ private void shutdownScheduler() {   try {"Performing Job Resources CleanUp");   Scheduler scheduler = SchedulerManager.getInstance().getScheduler();  if (scheduler != null) {    List jobExeContextList =  scheduler.getCurrentlyExecutingJobs();"There are " + jobExeContextList.size() + " running   jobs at shutdown.");    Iterator it = …

Read More »

How to send email for GoDaddy using Java?

package com.infuze.server.util;   import java.util.List; import java.util.Properties;   import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage;   import com.livrona.comono.logger.Logger; import com.livrona.comono.logger.LoggerFactory;   public class EmailHelper {   private static final Logger log = LoggerFactory.createLogger(EmailHelper.class);                 public static void sendMailViaGodaddy(String from, String …

Read More »

How to Read a File as Byte Array?

In order to get the contents of the file as array of bytes we use BufferedInputStream on top of FileInputStream. Once the file handle is open, we read the bytes from the file in chunks and copy the byte chunks in the buffer using the System.arraycopy.<!

Read More »
Advertisment ad adsense adlogger