java.lang.reflect.LogRecord的getResourceBundleName()方法用於獲取本地化資源包名稱。
用法:
public String getResourceBundleName()
參數:此方法不接受任何內容。
返回:此方法返回本地化資源包名稱。
以下示例程序旨在說明getResourceBundleName()方法:
示例1:
// Java program to illustrate
// getResourceBundleName() method
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.ResourceBundle;
public class GFG {
public static void main(String[] args)
{
// Create LogRecord object
LogRecord logRecord = new LogRecord(
Level.parse("800"),
"Hi Logger");
logRecord.setResourceBundleName(
"GFG Bundle");
// get ResourceBundle Name
String resourceBundleName
= logRecord.getResourceBundleName();
// print the ResourceBundle name
System.out.println(
"Resource Bundle = "
+ resourceBundleName);
}
}
輸出:
Resource Bundle = GFG Bundle
示例2:
// Java program to illustrate
// getResourceBundleName() method
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.ResourceBundle;
public class GFG {
public static void main(String[] args)
{
// Create LogRecord object
LogRecord logRecord = new LogRecord(
Level.parse("600"),
"GFG Logger");
logRecord.setResourceBundleName(
"LOGGER Bundle");
// get ResourceBundle Name
String resourceBundleName
= logRecord.getResourceBundleName();
// print the ResourceBundle name
System.out.println(
"Resource Bundle = "
+ resourceBundleName);
}
}
輸出:
Resource Bundle = LOGGER Bundle
參考文獻: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#getResourceBundleName()
相關用法
- Java Level getResourceBundleName()用法及代碼示例
- Java Logger getResourceBundleName()用法及代碼示例
- Java LogRecord setSequenceNumber()用法及代碼示例
- Java LogRecord setSourceMethodName()用法及代碼示例
- Java LogRecord setThrown()用法及代碼示例
- Java LogRecord setResourceBundleName()用法及代碼示例
- Java LogRecord setResourceBundle()用法及代碼示例
- Java LogRecord setInstant()用法及代碼示例
- Java LogRecord getSourceMethodName()用法及代碼示例
- Java LogRecord getInstant()用法及代碼示例
- Java LogRecord getMillis()用法及代碼示例
- Java LogRecord getResourceBundle()用法及代碼示例
- Java LogRecord getThrown()用法及代碼示例
- Java LogRecord getSourceClassName()用法及代碼示例
- Java LogRecord getParameters()用法及代碼示例
注:本文由純淨天空篩選整理自AmanSingh2210大神的英文原創作品 LogRecord getResourceBundleName() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。