Converting in between Blob and StringBuilder

From StringBuilder to Blob @Autowired private SessionFactory sessionFactory; //saving the blob field java.sql.Blob blob = org.hibernate.Hibernate.getLobCreator(sessionFactory.getCurrentSession()).createBlob(errorDescs.toString().getBytes()); From Blob to StringBuilder StringBuilder errorDescs = new StringBuilder(); //error description if (order.getBatchErrorDescription() == null){ errorDescs.append(response.getErrors().getDescription().toString() + ";"); } else{ try { Blob blob = order.getBatchErrorDescription(); byte[] byteData = blob.getBytes(1, (int) blob.length()); String data = new String(byteData); errorDescs.append(data) .append(response.getErrors().getDescription().toString()

Java SMTP mail sending code

final String username = "xxx"; final String password = "xxx"; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.host", "HOSTNAME"); props.put("mail.smtp.port", "587"); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); try { MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("abc@yahoo.de")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("rec1@yahoo.de, rec2@yahoo.de")); message.setSubject("YOUR SUBJEC", "utf-8"); String content