05-29-2009 07:45 AM
>config
… myConfigModule.properties
>source/java
… Java class which need myConfigModule.properties
06-02-2009 05:44 AM
getClass().getClassLoader().getResource("/your/classpath/right/here");
06-02-2009 05:49 AM
06-02-2009 11:48 AM
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) {
…
06-24-2009 07:48 AM
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
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.