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 API13 Feb 2010

How do I copy file using FileChannel class?

The example below show you how to copy a file using the java.nio.channels.FileChannel class. package org.kodejava.io; import java.io.*; import java.nio.channels.FileChannel; public class FileCopy { public static void main(String[] args) { //// Define the source and target file File source = new File("D:/Temp/source.txt"); File target = new File("D:/Temp/target.txt"); // Create the source and target channel try […]

Wayan · 1 min read
SERVLET / NOTES</>↗
Servlet13 Feb 2010

How do I create zip file in Servlet for download?

The example below is a servlet that shows you how to create a zip file and send the generated zip file for user to download. The compressing process is done by the zipFiles method of this class. For a servlet to work you need to configure it in the web.xml file of your web application […]

Wayan · 3 min read
GOOGLE GSON / NOTES</>↗
Google Gson10 Feb 2010

How do I convert Map into JSON?

This example show you how to convert a java.util.Map into JSON string and back to Map again. package org.kodejava.gson; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; public class MapToJson { public static void main(String[] args) { Map<String, String> colours = new HashMap<>(); colours.put("BLACK", "#000000"); colours.put("RED", "#FF0000"); colours.put("GREEN", "#008000");...

Wayan · 2 min read
GOOGLE GSON / NOTES</>↗
Google Gson08 Feb 2010

How do I convert collections into JSON?

This example show you how to convert Java collections object into JSON string. For Student class use in this example you can find it the previous example on How do I convert object into JSON?. package org.kodejava.gson; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import org.kodejava.gson.support.Student; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; public class […...

Wayan · 3 min read
GOOGLE GSON / NOTES</>↗
Google Gson04 Feb 2010

How do I convert array into JSON?

In the example below you can see how to convert an array into JSON string. We serialize the array to JSON using the Gson.toJson() method. To deserialize a string of JSON into array we use the Gson.fromJson() method. package org.kodejava.gson; import com.google.gson.Gson; public class ArrayToJson { public static void main(String[] args) { int[] numbers = […]

Wayan · 2 min read
GOOGLE GSON / NOTES</>↗
Google Gson03 Feb 2010

How does Gson handles object fields?

In this example you’ll see how the Gson library handles the object fields. For object fields to be serialized into JSON string it doesn’t need to use any annotations, it can even read private fields. If you have a null value field it will not be serialized into JSON string. To exclude a field from […]

Wayan · 2 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.