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

Java Snippets

How does SMTP debug looks like on sending email?

mymac:bin mv$ ./run.sh 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 “smtpout.secureserver.net”, port 25 DEBUG SMTP RCVD: 220 p3plsmtpa06-05.prod.phx3.secureserver.net ESMTP DEBUG: SMTPTransport connected to host “smtpout.secureserver.net”, port: 25 DEBUG SMTP SENT: EHLO mymac.localDEBUG SMTP RCVD: 250-p3plsmtpa06-05.prod.phx3.secureserver.net250-AUTH LOGIN PLAIN250-8BITMIME250 PIPELINING …

Read More »

How to cleanup Quartz Jobs on shutdown in Java?

/** * Shutdown the scheduler  */ private void shutdownScheduler() {   try {    log.info("Performing Job Resources CleanUp");   Scheduler scheduler = SchedulerManager.getInstance().getScheduler();  if (scheduler != null) {    List jobExeContextList =  scheduler.getCurrentlyExecutingJobs();    log.info("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