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.

GOOGLE GSON / NOTES</>↗
Google Gson01 Feb 2010

How do I convert JSON into object?

On the previous example, How do I convert object into JSON? we convert object into JSON string. In this example you will see how to do the opposite, converting JSON string back into object. To convert JSON string to object use Gson.fromJson() method. This method takes the JSON string and the object type of the […]

Wayan · 2 min read
GOOGLE GSON / NOTES</>↗
Google Gson30 Jan 2010

How do I convert object into JSON?

In this example we are using Google Gson to convert an object (Student object) into JSON notation. Practically we can use this library to convert any object in Java, and it is quite simple. You just need to create an instance of Gson class and then call the toJson() method and pass the object to […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API27 Jan 2010

How do I create a console progress bar?

The code below demonstrates how to create a progress bar in a console program. The trick is to print the progress status using a System.out.print() and add a carriage return character ("\r") at the end of the string to return the cursor position to the beginning of the line and print the next progress status. […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API23 Jan 2010

How do I calculate process execution time in higher resolution?

This example demonstrates how to use the System.nanoTime() method to calculate processing execution time in higher resolution. The processing time calculated in nanoseconds resolution. package org.kodejava.lang; public class NanoSecondsTimerResolution { public static void main(String[] args) { // Get process execution start time in nanoseconds. long start = System.nanoTime(); System.out.println("Process start… " + start); try { […]

Wayan · 1 min read
JDOM / NOTES</>↗
JDOM21 Jan 2010

How do I convert JDOM Document to String?

This example demonstrate how to convert JDOM Document object to a String using the XMLOutputter.outputString(Document doc) method. package org.kodejava.jdom; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; public class JDOMDocumentToString { public static void main(String[] args) { Document document = new Document(); Element root = new Element("rows"); // Creating a child for the root element. […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API17 Jan 2010

How do I get the default print service?

To look up the default print service we can use the javax.print.PrintServiceLookup class lookupDefaultPrintService() method. package org.kodejava.print; import javax.print.PrintService; import javax.print.PrintServiceLookup; public class GetPrinter { public static void main(String[] args) { // Gets the default print service for this environment. Null is returned when // no default print service found. PrintService service = PrintServiceLookup.lookupDefaultPrintService(); if [...

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.