Interface FileConfiguration
- All Known Subinterfaces:
EmbeddedPropertiesConfiguration
- All Known Implementing Classes:
EmbeddedPropertiesConfigurationImpl,YamlConfiguration
@Experimental
public interface FileConfiguration
Example usage:
public void loadConfigExample() {
try {
// 1. Tạo instance
FileConfiguration config = new YamlConfiguration();
// 2. Xác định file
File file = new File("config.yml");
// 3. Load (Nếu file chưa có thì tạo file mặc định - logic này bạn tự code thêm)
if (!file.exists()) {
file.createNewFile();
// Set default values
config.set("server.port", 8080);
config.set("bot.token", "default_token");
config.set("bot.owners", List.of("123", "456"));
config.save(file);
}
config.load(file);
// 4. Lấy dữ liệu (Dot notation)
String token = config.getString("bot.token");
int port = config.getInt("server.port");
List owners = config.getStringList("bot.owners");
System.out.println("Token: " + token);
} catch (IOException e) {
e.printStackTrace();
}
}
-
Method Summary
Modifier and TypeMethodDescriptionbooleanKiểm tra path có tồn tại không.Lấy giá trị Object thô.booleangetBoolean(String path) booleangetBoolean(String path, boolean def) doubledoubleintintList<?> getStringList(String path) voidTải dữ liệu từ file vào bộ nhớ.voidLưu dữ liệu từ bộ nhớ xuống file.voidSet giá trị vào path.
-
Method Details
-
load
Tải dữ liệu từ file vào bộ nhớ.- Throws:
IOException
-
save
Lưu dữ liệu từ bộ nhớ xuống file.- Throws:
IOException
-
get
Lấy giá trị Object thô. -
get
-
set
Set giá trị vào path. -
contains
Kiểm tra path có tồn tại không. -
getString
-
getString
-
getInt
-
getInt
-
getDouble
-
getDouble
-
getBoolean
-
getBoolean
-
getList
-
getStringList
-