ResourceBundle.clearCache() in Java

clearCache(): This method is available in java.util.ResourceBundle class of Java.

Syntax:

void java.util.ResourceBundle.clearCache()

This method removes all resource bundles from the cache that have been loaded by the caller's module.

Parameters: NA

Returns: NA

Exceptions: NA

Approach

Java

import java.util.Locale;
import java.util.ResourceBundle;

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

        ResourceBundle bundle =
ResourceBundle.getBundle("Hello", Locale.US);

        String key = "Hello";
        System.out.println(bundle.getString(key));
        ResourceBundle.clearCache();

    }
}

Output:

Hello Java Program



No comments:

Post a Comment