How do I get path / classpath separator?

OS platform has different symbol used for path separator. Path separator is a symbol that separate one path element from the other. In Windows the path separator is a semicolon symbol (;), you have something like:


While on Linux operating system the path separator is a colon symbol (:), it looks like:


To obtain the path separator you can use the following code.

package org.kodejava.example.lang;

import java.util.Properties;

public class PathSeparator {
    public static void main(String[] args) {
        // Get System properties
        Properties properties = System.getProperties();

        // Get the path separator which is unfortunately
        // using a different symbol in different OS platform.
        String pathSeparator = properties.getProperty("path.separator");
        System.out.println("pathSeparator = " + pathSeparator);

How do I read a configuration file using java.util.Properties?

When we have an application that used a text file to store a configuration and the configuration is typically in a key=value format then we can use java.util.Properties to read that configuration file.

Here is an example of a configuration file called app.config: Sample Code

The code below show you how to read the configuration.

package org.kodejava.example.util;

import java.util.Objects;
import java.util.Properties;

public class PropertiesExample {
    public static void main(String[] args) {
        Properties prop = new Properties();
        try {
            // the configuration file name
            String fileName = "app.config";
            ClassLoader classLoader =

            // Make sure that the configuration file exists
            URL res = Objects.requireNonNull(
                    "Can't find configuration file app.config");

            InputStream is = new FileInputStream(res.getFile());

            // load the properties file

            // get the value for key
            // get the value for app.version key

            // get the value for app.vendor key and if the
            // key is not available return Kode Java as
            // the default value
                    "Kode Java"));
        } catch (IOException e) {

The code snippet will print these results:

Properties Sample Code
Kode Java