@Test (expected = IllegalStateException.class) public void testLoadNotExistentDir () throws IOException { Config.loadDir(new File("../not-existent-dir/")); }
public static void loadDir (File dir) throws IOException { if (!dir.exists()) { throw new IllegalStateException("config directory doesn't exists: " + dir.getAbsolutePath()); } if (!dir.isDirectory()) { throw new IllegalArgumentException("dir isn't a directory!"); } File[] files = dir.listFiles(); for (File file : files) { if (!file.isFile()) { continue; } if (!file.getName().endsWith(".cfg") && !file.getName().endsWith(".ini")) { Log.v(LOG_TAG, "skip file: " + file.getAbsolutePath()); continue; } Config.load(file); } }
Config { public static void loadDir (File dir) throws IOException { if (!dir.exists()) { throw new IllegalStateException("config directory doesn't exists: " + dir.getAbsolutePath()); } if (!dir.isDirectory()) { throw new IllegalArgumentException("dir isn't a directory!"); } File[] files = dir.listFiles(); for (File file : files) { if (!file.isFile()) { continue; } if (!file.getName().endsWith(".cfg") && !file.getName().endsWith(".ini")) { Log.v(LOG_TAG, "skip file: " + file.getAbsolutePath()); continue; } Config.load(file); } } }
Config { public static void loadDir (File dir) throws IOException { if (!dir.exists()) { throw new IllegalStateException("config directory doesn't exists: " + dir.getAbsolutePath()); } if (!dir.isDirectory()) { throw new IllegalArgumentException("dir isn't a directory!"); } File[] files = dir.listFiles(); for (File file : files) { if (!file.isFile()) { continue; } if (!file.getName().endsWith(".cfg") && !file.getName().endsWith(".ini")) { Log.v(LOG_TAG, "skip file: " + file.getAbsolutePath()); continue; } Config.load(file); } } protected  Config(); }
Config { public static void loadDir (File dir) throws IOException { if (!dir.exists()) { throw new IllegalStateException("config directory doesn't exists: " + dir.getAbsolutePath()); } if (!dir.isDirectory()) { throw new IllegalArgumentException("dir isn't a directory!"); } File[] files = dir.listFiles(); for (File file : files) { if (!file.isFile()) { continue; } if (!file.getName().endsWith(".cfg") && !file.getName().endsWith(".ini")) { Log.v(LOG_TAG, "skip file: " + file.getAbsolutePath()); continue; } Config.load(file); } } protected  Config(); static void load(File file); static void load(File file, boolean skipExampleConfig); static void loadDir(File dir); static String get(String section, String key); static String getOrDefault(String section, String key, String defaultValue); static boolean getBool(String section, String key); static int getInt(String section, String key); static float getFloat(String section, String key); static void set(String section, String key, String value); static void reload(); static void clear(); }
Config { public static void loadDir (File dir) throws IOException { if (!dir.exists()) { throw new IllegalStateException("config directory doesn't exists: " + dir.getAbsolutePath()); } if (!dir.isDirectory()) { throw new IllegalArgumentException("dir isn't a directory!"); } File[] files = dir.listFiles(); for (File file : files) { if (!file.isFile()) { continue; } if (!file.getName().endsWith(".cfg") && !file.getName().endsWith(".ini")) { Log.v(LOG_TAG, "skip file: " + file.getAbsolutePath()); continue; } Config.load(file); } } protected  Config(); static void load(File file); static void load(File file, boolean skipExampleConfig); static void loadDir(File dir); static String get(String section, String key); static String getOrDefault(String section, String key, String defaultValue); static boolean getBool(String section, String key); static int getInt(String section, String key); static float getFloat(String section, String key); static void set(String section, String key, String value); static void reload(); static void clear(); static boolean forceExit; }