/** * Copyright (C) 2017 Christian Pierre MOMON * * This file is part of (April) Hebdobot. * * Hebdobot is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Hebdobot is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Hebdobot. If not, see */ package org.april.hebdobot.util; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Properties; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.math.NumberUtils; /** * The Class Launcher. */ public class HebdobotUtils { /** * Constructor restriction. */ private HebdobotUtils() { } /** * Load properties. * * @param source * the source * @return the properties * @throws IOException * Signals that an I/O exception has occurred. */ public static Properties loadProperties(final File source) throws IOException { Properties result; System.setProperty("file.encoding", "UTF-8"); result = new Properties(); FileReader reader = null; try { reader = new FileReader(source); result.load(reader); } finally { IOUtils.closeQuietly(reader); } // return result; } /** * To integer. * * @param value * the value * @return the integer */ public static Integer toInteger(final String value) { Integer result; if ((value == null) || (!NumberUtils.isDigits(value))) { result = null; } else { result = Integer.parseInt(value); } // return result; } }