SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

CORE API / NOTES</>↗
Core API12 Sep 2007

How do I convert milliseconds value to date?

package org.kodejava.util; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class MillisecondsToDate { public static void main(String[] args) { // Create a DateFormatter object for displaying date information. DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS"); // Get date and time information in milliseconds long now = System.currentTimeMillis(); // Create a calendar object that will convert the date […]

Wayan · 1 min read
MAIL / NOTES</>↗
Mail11 Sep 2007

How do I send an email with attachment?

In this example we create a small program to send email with a file attachment. To send message with attachment we need to create an email with javax.mail.Multipart object which basically will contain the email text message and then add a file to the second block, which both of them is an object of javax.mail.internet.MimeBodyPart. […]

Wayan · 3 min read
CORE API / NOTES</>↗
Core API07 Sep 2007

How do I split a string using Scanner class?

Instead of using the StringTokenizer class or the String.split() method we can use the java.util.Scanner class to split a string. package org.kodejava.util; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ScannerTokenDemo { public static void main(String[] args) { // This file contains some data as follows: // a, b, c, d // e, f, g, […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API04 Sep 2007

How do I read file line by line using java.util.Scanner class?

Here is a compact way to read file line by line using the java.util.Scanner class. package org.kodejava.util; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ScannerReadFile { public static void main(String[] args) { // Create an instance of File for data.txt file. File file = new File("README.md"); try { // Create a new Scanner object […]

Wayan · 1 min read
MAIL / NOTES</>↗
Mail31 Aug 2007

How do I send an email message?

To enable your application to send email you can use the JavaMail API, and prior to JDK 1.6 you will also need the JavaBeans Activation Framework. The JAF jar file should be included in your application classpath. package org.kodejava.mail; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.util.Properties; publi...

Wayan · 2 min read
SWING / NOTES</>↗
Swing26 Aug 2007

How do I right justified JTextField contents?

To right justified a JTextField contents we can call the setHorizontalAlignment(JTextField.RIGHT) method of the JTextField class. package org.kodejava.swing; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; public class TextFieldRightJustify extends JFrame { public TextFieldRightJustify() { initComponents(); } public...

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.