ServiceLoader reload() in Java

reload(): This method is available in java.util.ServiceLoader class of Java.

Syntax:

void java.util.ServiceLoader.reload()

This method clears this loader's provider cache so that all providers will be reloaded.

Parameters: NA

Returns: NA

Exceptions: NA

Approach

Java

import java.util.ServiceLoader;

public class ServiceLoaderreload {
    public static void main(String[] args) {

        ServiceLoader<String> serviceLoader =
ServiceLoader.load(String.class);

        serviceLoader.reload();

        System.out.println("Reloaded Succesfully");

    }

}

Output:

Reloaded Succesfully


No comments:

Post a Comment