📌  相关文章
📜  Java中的级别 getResourceBundleName() 方法和示例

📅  最后修改于: 2022-05-13 01:55:16.567000             🧑  作者: Mango

Java中的级别 getResourceBundleName() 方法和示例

Java.util.logging.LevelgetResourceBundleName()方法用于获取该关卡对象的本地化资源包名称。如果存在本地化包,则此方法返回包的名称,否则方法返回 null。

句法:

public String getResourceBundleName()

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

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

下面的程序说明了 getResourceBundleName() 方法:
方案一:

// 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

方案二:

// 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: Java/util/logging/Level.html#getResourceBundleName()