--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>de.laktatnebel.libs</groupId>
+ <artifactId>propertylib</artifactId>
+ <version>2.1.1-SNAPSHOT</version>
+
+ <name>PropertyLib</name>
+
+ <parent>
+ <groupId>de.laktatnebel.maven</groupId>
+ <artifactId>laktatnebellib</artifactId>
+ <version>2.1.7</version>
+ </parent>
+
+ <properties>
+ <commons-lang.version>2.6</commons-lang.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>${commons-lang.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*\r
+ * Projekt:\r
+ * Dateiname: PropertyReader.java\r
+ * Erzeugt: 07.01.2010\r
+ *\r
+ * Beschreibung:\r
+ *\r
+ *\r
+ ************************************************************************\r
+ * Modification History:\r
+ *\r
+ ************************************************************************\r
+ *\r
+ */\r
+package de.laktatnebel.libs.propertylib;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.File;\r
+import java.io.FileReader;\r
+import java.io.IOException;\r
+import java.io.StringReader;\r
+import java.nio.file.Files;\r
+import java.util.Iterator;\r
+import java.util.Properties;\r
+import java.util.Set;\r
+\r
+import org.apache.commons.lang.StringUtils;\r
+\r
+import de.laktatnebel.libs.propertylib.execption.PropertyReaderException;\r
+\r
+/**\r
+ * @author olgehrma\r
+ */\r
+public class PropertyReader {\r
+\r
+ public static final char CHAR_BACKSLASH = '\\';\r
+ public static final String CHAR_DOUBLEBACKSLASH = "\\\\";\r
+\r
+ public PropertyReader() {\r
+ super();\r
+ }\r
+\r
+ /**\r
+ * @param path\r
+ * Path to Property-File\r
+ * @return properties\r
+ * @throws IOException\r
+ * IOException\r
+ * @throws PropertyReaderException\r
+ */\r
+ @Deprecated\r
+ public static Properties readProperties(final String path) throws IOException, PropertyReaderException {\r
+\r
+ final Properties properties = new Properties();\r
+\r
+ final File propertyFile = new File(path + "gallery.properties");\r
+\r
+ BufferedReader br = null;\r
+\r
+ try {\r
+ final FileReader fr = new FileReader(propertyFile);\r
+ br = new BufferedReader(fr);\r
+\r
+ properties.load(br);\r
+\r
+ br.close();\r
+ } catch (final IOException ioe) {\r
+ throw new PropertyReaderException(ioe.getMessage(), ioe);\r
+ } finally {\r
+ if (br != null) {\r
+ br.close();\r
+ }\r
+ }\r
+\r
+ return properties;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @param args\r
+ * @return\r
+ * @throws PropertyReaderException\r
+ * @throws IOException\r
+ */\r
+ public static Properties readPropertiesWithFileSeparatorReplacement(final String pathToPropertyFile) throws PropertyReaderException {\r
+\r
+ // Properties einlesen\r
+ final Properties props = new Properties();\r
+\r
+ try {\r
+ final String propertiesString = new String(Files.readAllBytes(new File(pathToPropertyFile).toPath()));\r
+ props.load(new StringReader(propertiesString.replace(Character.toString(PropertyReader.CHAR_BACKSLASH), PropertyReader.CHAR_DOUBLEBACKSLASH)));\r
+ } catch (final IOException ioe) {\r
+ throw new PropertyReaderException(ioe.getMessage(), ioe);\r
+ }\r
+\r
+ return props;\r
+ }\r
+\r
+ /**\r
+ * @param properties\r
+ * Properties\r
+ * @return\r
+ */\r
+ public static StringBuffer examineProperties(final Properties properties) {\r
+ final StringBuffer sb = new StringBuffer("Properties-Size:\t" + properties.size());\r
+\r
+ final Set<Object> allPropertyKeys = properties.keySet();\r
+\r
+ final Iterator<Object> itAllPropertyKeys = allPropertyKeys.iterator();\r
+\r
+ while (itAllPropertyKeys.hasNext()) {\r
+ final Object obj = itAllPropertyKeys.next();\r
+ final String key = obj.toString();\r
+\r
+ sb.append(key + " = " + properties.getProperty(key));\r
+ }\r
+\r
+ return sb;\r
+ }\r
+\r
+ /**\r
+ * @return\r
+ * @throws IOException\r
+ * \r
+ */\r
+ public static String[] getPropertyValueArray(final Properties properties, final String propertyKey, final Character delim) {\r
+ return PropertyReader.getPropertyValueArray(properties, propertyKey, null, Character.toString(delim));\r
+ }\r
+\r
+ /**\r
+ * @return\r
+ * @throws IOException\r
+ * \r
+ */\r
+ public static String[] getPropertyValueArray(final Properties properties, final String propertyKey, final String propertyDefaultValue, final Character delim) {\r
+ return PropertyReader.getPropertyValueArray(properties, propertyKey, propertyDefaultValue, Character.toString(delim));\r
+ }\r
+\r
+ /**\r
+ * @return\r
+ * @throws IOException\r
+ * \r
+ */\r
+ public static String[] getPropertyValueArray(final Properties properties, final String propertyKey, final String delim) {\r
+ return PropertyReader.getPropertyValueArray(properties, propertyKey, null, delim);\r
+ }\r
+\r
+ /**\r
+ * @return\r
+ * @throws IOException\r
+ * \r
+ */\r
+ public static String[] getPropertyValueArray(final Properties properties, final String propertyKey, final String propertyDefaultValue, final String delim) {\r
+ String valueString = "";\r
+\r
+ if (propertyDefaultValue == null) {\r
+ valueString = properties.getProperty(propertyKey);\r
+ } else {\r
+ valueString = properties.getProperty(propertyKey, propertyDefaultValue);\r
+ }\r
+\r
+ return StringUtils.split(valueString.replaceAll("\\s+", ""), delim);\r
+ }\r
+\r
+}\r