As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
>config … myConfigModule.properties >source/java … Java class which need myConfigModule.properties
getClass().getClassLoader().getResource("/your/classpath/right/here");
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import org.apache.log4j.Logger; public class Tools implements configurationModule { private static Logger logger = Logger.getLogger(Tools.class); private static ClassLoader classLoader=Tools.class.getClassLoader(); // The method accessing the config file (file="/alfresco/module/truc/config/configModule.properties") public static String getValueInConfigFile(String file, String tagToRead) { StringBuilder contents = new StringBuilder(); String valueTag = null; try { InputStream stream = classLoader.getResourceAsStream(file); BufferedReader input = new BufferedReader(new InputStreamReader(stream)); try { String line = null; // not declared within while loop while ((line = input.readLine()) != null) { …
import java.util.Properties; … Properties prop = new Properties(); try{ prop.load(getClass().getResourceAsStream("/alfresco/module/truc/config/configModule.properties")); } catch(Exception e){ System.err.println("Can not load configModule.properties"); } // Get the values String server = prop.getProperty("server");
server=10.10.10.2