Update tests
This commit is contained in:
1 parent
6544e982c6
commit
5f1cbad0ee
3 files changed
+63
-9
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package netneutrality.utils;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -12,17 +14,28 @@ public class Settings {
|
||||
private final Properties prop = new Properties();
|
||||
|
||||
public Settings() {
|
||||
File file = new File("bot.properties");
|
||||
File propFile = new File("bot.properties");
|
||||
File exampleFile = new File("bot.properties.example");
|
||||
FileInputStream fis = null;
|
||||
|
||||
try {
|
||||
file.createNewFile();
|
||||
fis = new FileInputStream(file);
|
||||
if (!propFile.exists() && !exampleFile.exists()) {
|
||||
System.err.println("Missing example config file in root directory.");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (!propFile.exists()) {
|
||||
FileUtils.copyFile(exampleFile, propFile);
|
||||
System.err.println("Config file was created, please edit bot.properties before launching bot");
|
||||
}
|
||||
|
||||
fis = new FileInputStream(propFile);
|
||||
prop.load(fis);
|
||||
|
||||
loadEnvironmentVariables();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Can't find config file: bot.properties");
|
||||
System.exit(1);
|
||||
} finally {
|
||||
try {
|
||||
if (fis != null)
|
||||
|
||||
Reference in new issue
Block a user