当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java Level getResourceBundleName()用法及代码示例


java.util.logging.Level的getResourceBundleName()方法用于获取此级别对象的本地化资源包名称。如果存在本地化包,则此方法返回包的名称,否则返回null。

用法:

public String getResourceBundleName()

参数:此方法不接受任何内容。


返回:此方法返回本地化资源包名称。

以下示例程序旨在说明getResourceBundleName()方法:
示例1:

// Java program to illustrate 
// getResourceBundleName() method 
  
import java.util.ResourceBundle; 
import java.util.logging.Level; 
import java.util.logging.Logger; 
  
public class GFG { 
  
    public static void main(String[] args) 
    { 
  
        // Create a Logger 
        Logger logger 
            = Logger.getLogger( 
                        Object.class.getName()) 
                  .getParent(); 
  
        // Get level of logger 
        Level level 
            = logger.getLevel(); 
  
        // get localization resource bundle name 
        String name = level.getResourceBundleName(); 
  
        // print level localization resource bundle name 
        System.out.println("Localization resource"
                           + " bundle name = "
                           + name); 
    } 
}
输出:
Localization resource bundle name = sun.util.logging.resources.logging

示例2:

// Java program to illustrate 
// getResourceBundleName() method 
  
import java.util.logging.Level; 
  
public class GFG { 
  
    public static void main(String[] args) 
    { 
  
        // Get level of logger 
        Level level 
            = Level.parse("SEVERE"); 
  
        // get localization resource bundle name 
        String name = level.getResourceBundleName(); 
  
        // print level localization resource bundle name 
        System.out.println("Localization resource"
                           + " bundle name = "
                           + name); 
    } 
}
输出:
Localization resource bundle name = sun.util.logging.resources.logging

参考文献: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Level.html#getResourceBundleName()



相关用法


注:本文由纯净天空筛选整理自AmanSingh2210大神的英文原创作品 Level getResourceBundleName() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。