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 API27 Apr 2010

How do I get the extension of a file?

Below is an example that can be used to get the extension of a file. The code below assume that the extension is the last part of the file name after the last dot symbol. For instance if you have a file named data.txt the extension will be txt, but if you have a file […]

Wayan · 2 min read
REGEX / NOTES</>↗
Regex25 Apr 2010

How do I check if a string starts with a pattern?

The example below demonstrate the Matcher.lookingAt() method to check if a string starts with a pattern represented by the Pattern class. package org.kodejava.regex; import java.util.Locale; import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; public class MatcherLookingAtExample { public static void main(String[] args) { // Get the available countries Set<String> countries = new TreeSet<>(); Locale[] locales […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API24 Apr 2010

How do I trim the capacity of an ArrayList?

For minimizing the storage used by an ArrayList to the number of its elements we can use the ArrayList.trimToSize() method call. In the code below we create an instance of ArrayList with the initial capacity set to 100. Later we only add five data into the list. To make the capacity of the ArrayList minimized […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API22 Apr 2010

How do I get process ID of a Java application?

The code below show you how to get the process ID of a Java application. We can use the ManagementFactory.getRuntimeMXBean().getName() to get the process ID. In Windows the method return a string in the form of [PID]@[MACHINE_NAME]. Since JDK 10, we can use ManagementFactory.getRuntimeMXBean().getPid() method to get the process ID. This method returns the process […]

Wayan · 2 min read
REGEX / NOTES</>↗
Regex21 Apr 2010

How do I find and replace string?

The code below demonstrates the use Matcher.appendReplacement() and Matcher.appendTail() methods to create a program to find and replace a sub string within a string. Another solution that can be used to search and replace a string can be found on the following example: How do I create a string search and replace using regex?. package […]

Wayan · 2 min read
AWT / NOTES</>↗
AWT19 Apr 2010

How do I print a file using the default registered application?

The example code below shows you how to print a file using the default registered application’s print command for the corresponding file type. As an example, on Windows notepad.exe is the default application for printing a .txt file. To print a file using the default registered application we call the java.awt.Desktop.print(File) method. The print() method […]

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.