// Path: happycoding/src/main/java/happy/coding/system/Systems.java
// public class Systems {
// 	private static String desktopPath = null;
// 
// 	public final static String FILE_SEPARATOR = System.getProperty("file.separator");
// 	public final static String USER_NAME = System.getProperty("user.name");
// 	public final static String USER_DIRECTORY = System.getProperty("user.home");
// 	public final static String WORKING_DIRECTORY = System.getProperty("user.dir");
// 	public final static String OPERATING_SYSTEM = System.getProperty("os.name");
// 
// 	public enum OS {
// 		Windows, Linux, Mac
// 	}
// 
// 	private static OS os = null;
// 
// 	/**
// 	 * @return path to the desktop with a file separator in the end
// 	 */
// 	public static String getDesktop() {
// 		if (desktopPath == null)
// 			desktopPath = USER_DIRECTORY + FILE_SEPARATOR + "Desktop" + FILE_SEPARATOR;
// 		return desktopPath;
// 	}
// 
// 	public static String getIP() {
// 		InetAddress ip = null;
// 		try {
// 			ip = InetAddress.getLocalHost();
// 		} catch (UnknownHostException e) {
// 			e.printStackTrace();
// 		}
// 		return ip.getHostName() + "@" + ip.getHostAddress();
// 	}
// 
// 	public static OS getOs() {
// 		if (os == null) {
// 			for (OS m : OS.values()) {
// 				if (OPERATING_SYSTEM.toLowerCase().contains(m.name().toLowerCase())) {
// 					os = m;
// 					break;
// 				}
// 			}
// 		}
// 		return os;
// 	}
// 
// 	public static void pause() {
// 		try {
// 			Logs.debug("System paused, press [enter] to continue ...");
// 			System.in.read();
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
//  
// 	public static void captureScreen() throws Exception {
// 		captureScreen("screenshot.png");
// 	}
// 
// 	public static void captureScreen(String fileName) throws Exception {
// 
// 		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// 		Rectangle screenRectangle = new Rectangle(screenSize);
// 		Robot robot = new Robot();
// 		BufferedImage image = robot.createScreenCapture(screenRectangle);
// 
// 		File file = new File(fileName);
// 		ImageIO.write(image, "png", file);
// 
// 		Logs.debug("A screenshot is captured to: {}", file.getPath());
// 	}
// 
// }


import happy.coding.system.Systems;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
package happy.coding.io;



/**
 * A configure class for .conf/.properties file
 * 
 * @author guoguibing
 * 
 */
public class FileConfiger extends StringMap {
	private Properties p = null;

	public FileConfiger(String conf) throws Exception {
		p = new Properties();
		p.load(new FileInputStream(FileIO.getResource(conf)));
	}

	public LineConfiger getParamOptions(String key) {
		String lineOptions = getString(key);
		return lineOptions == null ? null : new LineConfiger(lineOptions);
	}

	/**
	 * @return the key value as a trimmed string
	 * 
	 */
	public String getString(String key) {
		String str = p.getProperty(key);
		return str == null ? str : str.trim();
	}

	/**
	 * set a value to a specific key
	 * 
	 * @param key
	 *            property key
	 * @param val
	 *            property value
	 */
	public void setString(String key, String val) {
		p.setProperty(key, val);
	}

	/**
	 * @return the file IO path: supporting windows, linux and unix
	 */
	public String getPath(String key) {

		// first search key itself
		String path = getString(key);
		if (path != null)
			return path;

		// if not, considering the following cases
// Path: happycoding/src/main/java/happy/coding/system/Systems.java
// public class Systems {
// 	private static String desktopPath = null;
// 
// 	public final static String FILE_SEPARATOR = System.getProperty("file.separator");
// 	public final static String USER_NAME = System.getProperty("user.name");
// 	public final static String USER_DIRECTORY = System.getProperty("user.home");
// 	public final static String WORKING_DIRECTORY = System.getProperty("user.dir");
// 	public final static String OPERATING_SYSTEM = System.getProperty("os.name");
// 
// 	public enum OS {
// 		Windows, Linux, Mac
// 	}
// 
// 	private static OS os = null;
// 
// 	/**
// 	 * @return path to the desktop with a file separator in the end
// 	 */
// 	public static String getDesktop() {
// 		if (desktopPath == null)
// 			desktopPath = USER_DIRECTORY + FILE_SEPARATOR + "Desktop" + FILE_SEPARATOR;
// 		return desktopPath;
// 	}
// 
// 	public static String getIP() {
// 		InetAddress ip = null;
// 		try {
// 			ip = InetAddress.getLocalHost();
// 		} catch (UnknownHostException e) {
// 			e.printStackTrace();
// 		}
// 		return ip.getHostName() + "@" + ip.getHostAddress();
// 	}
// 
// 	public static OS getOs() {
// 		if (os == null) {
// 			for (OS m : OS.values()) {
// 				if (OPERATING_SYSTEM.toLowerCase().contains(m.name().toLowerCase())) {
// 					os = m;
// 					break;
// 				}
// 			}
// 		}
// 		return os;
// 	}
// 
// 	public static void pause() {
// 		try {
// 			Logs.debug("System paused, press [enter] to continue ...");
// 			System.in.read();
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
//  
// 	public static void captureScreen() throws Exception {
// 		captureScreen("screenshot.png");
// 	}
// 
// 	public static void captureScreen(String fileName) throws Exception {
// 
// 		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// 		Rectangle screenRectangle = new Rectangle(screenSize);
// 		Robot robot = new Robot();
// 		BufferedImage image = robot.createScreenCapture(screenRectangle);
// 
// 		File file = new File(fileName);
// 		ImageIO.write(image, "png", file);
// 
// 		Logs.debug("A screenshot is captured to: {}", file.getPath());
// 	}
// 
// }


// Path: happycoding/src/main/java/happy/coding/io/FileConfiger.java
import happy.coding.system.Systems;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;

package happy.coding.io;



/**
 * A configure class for .conf/.properties file
 * 
 * @author guoguibing
 * 
 */
public class FileConfiger extends StringMap {
	private Properties p = null;

	public FileConfiger(String conf) throws Exception {
		p = new Properties();
		p.load(new FileInputStream(FileIO.getResource(conf)));
	}

	public LineConfiger getParamOptions(String key) {
		String lineOptions = getString(key);
		return lineOptions == null ? null : new LineConfiger(lineOptions);
	}

	/**
	 * @return the key value as a trimmed string
	 * 
	 */
	public String getString(String key) {
		String str = p.getProperty(key);
		return str == null ? str : str.trim();
	}

	/**
	 * set a value to a specific key
	 * 
	 * @param key
	 *            property key
	 * @param val
	 *            property value
	 */
	public void setString(String key, String val) {
		p.setProperty(key, val);
	}

	/**
	 * @return the file IO path: supporting windows, linux and unix
	 */
	public String getPath(String key) {

		// first search key itself
		String path = getString(key);
		if (path != null)
			return path;

		// if not, considering the following cases
		switch (Systems.getOs()) {