'Java how to check if ResourceBundle is valid (expired or cleared from cache)

Java how to check if ResourceBundle is valid (expired or cleared from cache)?

ResourceBundle resourceBundle = ResourceBundle.getBundle(baseName, locale, ...);

resourceBundle.getString("abc");

The resourceBundle can be expired or have been removed from cache. How to check it before calling getString(...) method?



Solution 1:[1]

I think you are looking for ResourceBundle.Control.getTimeToLive(...) and ResourceBundle.Control.needsReload(...)

Java 11 Docs here:

getTimeToLive

needsReload

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 clawfair