List of usage examples for java.util Properties loadFromXML
public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException
From source file:Main.java
public static void main(String args[]) throws Exception { Properties prop = new Properties(); FileInputStream fis = new FileInputStream("sampleprops.xml"); prop.loadFromXML(fis); prop.list(System.out);/*from w ww . j a v a2 s.c om*/ System.out.println("\nThe foo property: " + prop.getProperty("foo")); }
From source file:Main.java
public static void main(String args[]) throws Exception { Properties p = new Properties(); p.put("today", new Date().toString()); p.put("user", "A"); FileOutputStream out = new FileOutputStream("user.props"); p.storeToXML(out, "updated"); FileInputStream in = new FileInputStream("user.props"); p.loadFromXML(in); p.list(System.out);// www . ja va 2 s . c om }
From source file:org.esxx.Main.java
public static void main(String[] args) { // (Try to) Load embedded H2 database JDBC driver into memory try {//from ww w. j a v a2 s. c o m Class.forName("org.h2.Driver"); } catch (ClassNotFoundException ignored) { } Options opt = new Options(); OptionGroup mode_opt = new OptionGroup(); // (Remember: -u/--user, -p/--pidfile and -j/jvmargs are used by the wrapper script) mode_opt.addOption(new Option("b", "bind", true, ("Listen for FastCGI requests on " + "this <port>"))); mode_opt.addOption(new Option("A", "ajp", true, ("Listen for AJP13 requests on " + "this <port>"))); mode_opt.addOption(new Option("H", "http", true, ("Listen for HTTP requests on " + "this <port>"))); mode_opt.addOption(new Option("s", "script", false, "Force script mode.")); mode_opt.addOption(new Option("S", "shell", false, "Enter ESXX shell mode.")); mode_opt.addOption(new Option(null, "db-console", false, "Open H2's database console.")); mode_opt.addOption(new Option(null, "version", false, "Display version and exit")); opt.addOptionGroup(mode_opt); opt.addOption("n", "no-handler", true, "FCGI requests are direct, without extra handler"); opt.addOption("r", "http-root", true, "Set AJP/FCGI/HTTP root directory (or file)"); // opt.addOption("d", "enable-debugger", false, "Enable esxx.debug()"); // opt.addOption("D", "start-debugger", false, "Start debugger"); opt.addOption("?", "help", false, "Show help"); try { CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(opt, args, false); int fastcgi_port = -1; int ajp_port = -1; int http_port = -1; boolean run_shell = false; String[] script = null; if (cmd.hasOption('?')) { usage(opt, null, 0); } if (cmd.hasOption('b')) { fastcgi_port = Integer.parseInt(cmd.getOptionValue('b')); } else if (cmd.hasOption('A')) { ajp_port = Integer.parseInt(cmd.getOptionValue('A')); } else if (cmd.hasOption('H')) { http_port = Integer.parseInt(cmd.getOptionValue('H')); } else if (cmd.hasOption('s')) { script = cmd.getArgs(); } else if (cmd.hasOption('S')) { run_shell = true; } else if (cmd.hasOption("db-console")) { org.h2.tools.Console.main(cmd.getArgs()); return; } else if (cmd.hasOption("version")) { Properties p = new Properties(); p.loadFromXML(Main.class.getResourceAsStream("/rsrc/esxx.properties")); System.err.println(p.getProperty("version")); return; } else { // Guess execution mode by looking at FCGI_PORT String fcgi_port = System.getenv("FCGI_PORT"); if (fcgi_port != null) { fastcgi_port = Integer.parseInt(fcgi_port); } else { // Default mode is to execute a JS script script = cmd.getArgs(); } } if (script != null) { Properties p = System.getProperties(); String forever = Long.toString(3600 * 24 * 365 * 10 /* 10 years */); // "Never" unload Applications in script mode p.setProperty("esxx.cache.apps.max_age", forever); // Kill process immediately on Ctrl-C p.setProperty("esxx.app.clean_shutdown", "false"); } ESXX esxx = ESXX.initInstance(System.getProperties(), null); if (script != null || run_shell) { // Lower default log level a bit esxx.getLogger().setLevel(java.util.logging.Level.INFO); } esxx.setNoHandlerMode(cmd.getOptionValue('n', "lighttpd.*")); // Install our ResponseCache implementation // java.net.ResponseCache.setDefault(new org.esxx.cache.DBResponseCache("/tmp/ESXX.WebCache", // Integer.MAX_VALUE, // Long.MAX_VALUE, // Long.MAX_VALUE)); // Default is to serve the current directory URI fs_root_uri = ESXX.createFSRootURI(cmd.getOptionValue('r', "")); if (fastcgi_port != -1 && !cmd.hasOption('r')) { // If not provided in FastCGI mode, use ${PATH_TRANSLATED} fs_root_uri = null; } if (fastcgi_port != -1) { FCGIRequest.runServer(fastcgi_port, fs_root_uri); } else if (ajp_port != -1) { Jetty.runJettyServer(-1, ajp_port, fs_root_uri); } else if (http_port != -1) { Jetty.runJettyServer(http_port, -1, fs_root_uri); } else if (run_shell) { ShellRequest sr = new ShellRequest(); sr.initRequest(); ESXX.Workload wl = esxx.addRequest(sr, sr, -1 /* no timeout for the shell */); try { System.exit((Integer) wl.getResult()); } catch (java.util.concurrent.CancellationException ex) { ex.printStackTrace(); System.exit(5); } } else if (script != null && script.length != 0) { File file = new File(script[0]); ScriptRequest sr = new ScriptRequest(); sr.initRequest(file.toURI(), script); ESXX.Workload wl = esxx.addRequest(sr, sr, -1 /* no timeout for scripts */); try { System.exit((Integer) wl.getResult()); } catch (java.util.concurrent.CancellationException ex) { ex.printStackTrace(); System.exit(5); } } else { usage(opt, "Required argument missing", 10); } } catch (ParseException ex) { usage(opt, ex.getMessage(), 10); } catch (IOException ex) { System.err.println("I/O error: " + ex.getMessage()); System.exit(20); } catch (Exception ex) { ex.printStackTrace(); System.exit(20); } System.exit(0); }
From source file:net.tirasa.ilgrosso.lngenerator.Main.java
public static void main(final String[] args) throws IOException, URISyntaxException { assert args.length > 0 : "No arguments provided"; File source = new File(args[0]); if (!source.isDirectory()) { throw new IllegalArgumentException("Not a directory: " + args[0]); }// w ww .j av a2 s .com String destPath = args.length > 1 ? args[1] : System.getProperty("java.io.tmpdir"); File dest = new File(destPath); if (!dest.isDirectory() || !dest.canWrite()) { throw new IllegalArgumentException("Not a directory, or not writable: " + destPath); } LOG.debug("Local Maven repo is {}", LOCAL_M2_REPO); LOG.debug("Source Path is {}", source.getAbsolutePath()); LOG.debug("Destination Path is {}", dest.getAbsolutePath()); LOG.warn("Existing LICENSE and NOTICE files in {} will be overwritten!", dest.getAbsolutePath()); Set<String> keys = new HashSet<>(); Files.walk(source.toPath()).filter(Files::isRegularFile) .map((final Path path) -> path.getFileName().toString()) .filter((String path) -> path.endsWith(".jar")).sorted().forEach((filename) -> { try (Stream<Path> stream = Files.find(LOCAL_M2_REPO_PATH, 10, (path, attr) -> String.valueOf(path.getFileName().toString()).equals(filename))) { String fullPath = stream.sorted().map(String::valueOf).collect(Collectors.joining("; ")); if (fullPath.isEmpty()) { LOG.warn("Could not find {} in the local Maven repo", filename); } else { String path = fullPath.substring(LOCAL_M2_REPO.length() + 1); Gav gav = GAV_CALCULATOR.pathToGav(path); if (gav == null) { LOG.error("Invalid Maven path: {}", path); } else if (!gav.getGroupId().startsWith("org.apache.") && !gav.getGroupId().startsWith("commons-") && !gav.getGroupId().equals("org.codehaus.groovy") && !gav.getGroupId().equals("jakarta-regexp") && !gav.getGroupId().equals("xml-apis") && !gav.getGroupId().equals("batik")) { if (ArrayUtils.contains(CONSOLIDATING_GROUP_IDS, gav.getGroupId())) { keys.add(gav.getGroupId()); } else if (gav.getGroupId().startsWith("com.fasterxml.jackson")) { keys.add("com.fasterxml.jackson"); } else if (gav.getGroupId().equals("org.webjars.bower") && (gav.getArtifactId() .startsWith("angular-animate") || gav.getArtifactId().startsWith("angular-cookies") || gav.getArtifactId().startsWith("angular-resource") || gav.getArtifactId().startsWith("angular-sanitize") || gav.getArtifactId().startsWith("angular-treasure-overlay-spinner"))) { keys.add("org.webjars.bower:angular"); } else if (gav.getGroupId().equals("org.webjars.bower") && gav.getArtifactId().startsWith("angular-translate")) { keys.add("org.webjars.bower:angular-translate"); } else if (gav.getGroupId().startsWith("de.agilecoders")) { keys.add("wicket-bootstrap"); } else if ("org.webjars".equals(gav.getGroupId())) { if (gav.getArtifactId().startsWith("jquery-ui")) { keys.add("jquery-ui"); } else { keys.add(gav.getArtifactId()); } } else { keys.add(gav.getGroupId() + ":" + gav.getArtifactId()); } } } } catch (IOException e) { LOG.error("While looking for Maven artifacts from the local Maven repo", e); } }); final Properties licenses = new Properties(); licenses.loadFromXML(Main.class.getResourceAsStream("/licenses.xml")); final Properties notices = new Properties(); notices.loadFromXML(Main.class.getResourceAsStream("/notices.xml")); BufferedWriter licenseWriter = Files.newBufferedWriter(new File(dest, "LICENSE").toPath(), StandardOpenOption.CREATE); licenseWriter.write( new String(Files.readAllBytes(Paths.get(Main.class.getResource("/LICENSE.template").toURI())))); BufferedWriter noticeWriter = Files.newBufferedWriter(new File(dest, "NOTICE").toPath(), StandardOpenOption.CREATE); noticeWriter.write( new String(Files.readAllBytes(Paths.get(Main.class.getResource("/NOTICE.template").toURI())))); EnumSet<LICENSE> outputLicenses = EnumSet.noneOf(LICENSE.class); keys.stream().sorted().forEach((final String dependency) -> { if (licenses.getProperty(dependency) == null) { LOG.error("Could not find license information about {}", dependency); } else { try { licenseWriter.write("\n==\n\nFor " + licenses.getProperty(dependency) + ":\n"); String depLicense = licenses.getProperty(dependency + ".license"); if (depLicense == null) { licenseWriter.write("This is licensed under the AL 2.0, see above."); } else { LICENSE license = LICENSE.valueOf(depLicense); if (license == LICENSE.PUBLIC_DOMAIN) { licenseWriter.write("This is " + license.getLabel() + "."); } else { licenseWriter.write("This is licensed under the " + license.getLabel()); if (outputLicenses.contains(license)) { licenseWriter.write(", see above."); } else { outputLicenses.add(license); licenseWriter.write(":\n\n"); licenseWriter.write(new String(Files.readAllBytes( Paths.get(Main.class.getResource("/LICENSE." + license.name()).toURI())))); } } } licenseWriter.write('\n'); if (notices.getProperty(dependency) != null) { noticeWriter.write("\n==\n\n" + notices.getProperty(dependency) + "\n"); } } catch (Exception e) { LOG.error("While dealing with {}", dependency, e); } } }); licenseWriter.close(); noticeWriter.close(); LOG.debug("Execution completed successfully, look at {} for the generated LICENSE and NOTICE files", dest.getAbsolutePath()); }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties prop = new Properties(); prop.put("Chapter Count", "200"); prop.put("Tutorial Count", "15"); // create a output and input as a xml file FileOutputStream fos = new FileOutputStream("properties.xml"); FileInputStream fis = new FileInputStream("properties.xml"); // store the properties in the specific xml prop.storeToXML(fos, null);/*from ww w.jav a 2s . co m*/ // load from the xml that we saved earlier prop.loadFromXML(fis); // print the properties list prop.list(System.out); }
From source file:org.apache.ctakes.ytex.kernel.dao.ConceptDaoImpl.java
/** * create a concept graph.//from w w w .j a v a 2 s.c o m * * This expects a property file in the classpath under * CONCEPT_GRAPH_PATH/[name].xml * <p/> * If the properties file is found in a directory, the concept graph will be * written there. * <p/> * Else (e.g. if the props file is coming from a jar), the concept graph * will be written to the directory specified via the system property/ytex * property 'org.apache.ctakes.ytex.conceptGraphDir' * <p/> * Else if the 'org.apache.ctakes.ytex.conceptGraphDir' property is not * defined, the concept graph will be written to the conceptGraph * subdirectory relative to ytex.properties (if ytex.properties is in a * directory). * * @param args */ @SuppressWarnings("static-access") public static void main(String args[]) throws ParseException, IOException { Options options = new Options(); options.addOption(OptionBuilder.withArgName("name").hasArg().isRequired() .withDescription("name of concept graph. A property file with the name " + CONCEPT_GRAPH_PATH + "/[name].xml must exist on the classpath") .create("name")); try { CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(options, args); String name = line.getOptionValue("name"); String propRes = CONCEPT_GRAPH_PATH + name + ".xml"; URL url = ConceptDaoImpl.class.getClassLoader().getResource(propRes); if (url == null) { System.out.println("properties file could not be located: " + propRes); return; } // load properties Properties props = new Properties(); InputStream is = ConceptDaoImpl.class.getClassLoader().getResourceAsStream(propRes); try { props.loadFromXML(is); } finally { is.close(); } // determine directory for concept graph - attempt to put in same // dir as props File fDir = null; if ("file".equals(url.getProtocol())) { File f; try { f = new File(url.toURI()); } catch (URISyntaxException e) { f = new File(url.getPath()); } fDir = f.getParentFile(); } String conceptGraphQuery = props.getProperty("ytex.conceptGraphQuery"); String strCheckCycle = props.getProperty("ytex.checkCycle", "true"); String forbiddenConceptList = props.getProperty("ytex.forbiddenConcepts"); Set<String> forbiddenConcepts; if (forbiddenConceptList != null) { forbiddenConcepts = new HashSet<String>(); forbiddenConcepts.addAll(Arrays.asList(forbiddenConceptList.split(","))); } else { forbiddenConcepts = defaultForbiddenConcepts; } boolean checkCycle = true; if ("false".equalsIgnoreCase(strCheckCycle) || "no".equalsIgnoreCase(strCheckCycle)) checkCycle = false; if (!Strings.isNullOrEmpty(name) && !Strings.isNullOrEmpty(conceptGraphQuery)) { KernelContextHolder.getApplicationContext().getBean(ConceptDao.class).createConceptGraph( fDir != null ? fDir.getAbsolutePath() : null, name, conceptGraphQuery, checkCycle, forbiddenConcepts); } else { printHelp(options); } } catch (ParseException pe) { printHelp(options); } }
From source file:org.schreibubi.JCombinationsTools.mergeResults.MergeResults.java
/** * @param args/*from w ww.jav a 2s .co m*/ */ @SuppressWarnings("static-access") public static void main(String[] args) { Options options = new Options(); try { Properties defaultProperties = new Properties(); Properties userProperties = new Properties(defaultProperties); defaultProperties.setProperty("triggerTrimColumn", "TRIM"); defaultProperties.setProperty("triggerMeasureColumn", "MEASURE"); defaultProperties.setProperty("trimColumns", "TRIM_TESTMODE,TRIM_TRIMMING,TRIM_RELATIVE,TRIM_ABS,TRIM_PATNAME,FORCE_VALUE"); defaultProperties.setProperty("trimAbsColumn", "TRIM_ABS"); defaultProperties.setProperty("trimRelativeColumn", "TRIM_RELATIVE"); defaultProperties.setProperty("subtitleColumn", "COMMENT"); defaultProperties.setProperty("dutSelection", "1-1024"); defaultProperties.setProperty("dutOffset", "32"); defaultProperties.setProperty("zip", "false"); try { userProperties.loadFromXML(new FileInputStream("config.xml")); } catch (FileNotFoundException e) { } String dclogFile = ""; ArrayList<String> dclogFiles = new ArrayList<String>(); String outputFile = ""; String combinationsFile = ""; String triggerTrimColumn = userProperties.getProperty("triggerTrimColumn"); String triggerMeasureColumn = userProperties.getProperty("triggerMeasureColumn"); String trimColumnsString = userProperties.getProperty("trimColumns"); String trimAbsColumn = userProperties.getProperty("trimAbsColumn"); String trimRelativeColumn = userProperties.getProperty("trimRelativeColumn"); String subtitleColumn = userProperties.getProperty("subtitleColumn"); String dutSelectionString = userProperties.getProperty("dutSelection"); String dutOffsetString = userProperties.getProperty("dutOffset"); boolean zip = Boolean.parseBoolean(userProperties.getProperty("zip")); CommandLineParser CLparser = new PosixParser(); // create the Options options.addOption(OptionBuilder.withLongOpt("dclog").withDescription("[in] dclog-files").hasArg() .withArgName("file").create('d')); options.addOption(OptionBuilder.isRequired().withLongOpt("combinations") .withDescription("[in] combinations file").hasArg().withArgName("file").create('c')); options.addOption(OptionBuilder.withLongOpt("output").withDescription("[out] output file").hasArg() .withArgName("file").create('o')); options.addOption(OptionBuilder.withLongOpt("trim") .withDescription("Column name of trim column, defaults to " + triggerTrimColumn).hasArg() .withArgName("column").create('t')); options.addOption(OptionBuilder.withLongOpt("measure") .withDescription("Column name of measure column, defaults to " + triggerMeasureColumn).hasArg() .withArgName("column").create('m')); options.addOption(OptionBuilder.withLongOpt("xvals") .withDescription("Column name containing the x-values, defaults to " + trimColumnsString) .hasArg().withArgName("column").create('x')); options.addOption(OptionBuilder.withLongOpt("relative") .withDescription( "Column name containing the relative changes, defaults to " + trimRelativeColumn) .hasArg().withArgName("column").create('r')); options.addOption(OptionBuilder.withLongOpt("subtitle") .withDescription( "Column name containing the subtitles for the shmoos, defaults to " + subtitleColumn) .hasArg().withArgName("column").create('s')); options.addOption(OptionBuilder.withLongOpt("zip").withDescription("zip output file").create('z')); options.addOption( OptionBuilder.withLongOpt("dut").withDescription("use only DUTs " + dutSelectionString).hasArg() .withArgName("column").create('u')); options.addOption(OptionBuilder.withLongOpt("dutOffset") .withDescription("dut offset when merging multiple measurments " + dutOffsetString).hasArg() .withArgName("offset").create('f')); options.addOption(OptionBuilder.withLongOpt("version").withDescription("version").create('v')); CommandLine line = CLparser.parse(options, args); if (line.hasOption("v")) { Info.printVersion("MergeResults"); Runtime.getRuntime().exit(0); } if (line.hasOption("c")) { combinationsFile = line.getOptionValue("c"); } if (line.hasOption("d")) { dclogFile = line.getOptionValue("d"); String[] dF = dclogFile.split(","); for (String s : dF) { dclogFiles.add(s); } } else { int dotPos = combinationsFile.lastIndexOf("."); if (dotPos > -1) { dclogFiles.add("dclog_af_b_source.csv_" + combinationsFile.substring(0, dotPos)); } else { dclogFiles.add("dclog_af_b_source.csv_" + combinationsFile); } } if (line.hasOption("o")) { outputFile = line.getOptionValue("o"); } else { int dotPos = combinationsFile.lastIndexOf("."); if (dotPos > -1) { outputFile = combinationsFile.substring(0, dotPos) + ".xml"; } else { outputFile = combinationsFile + ".xml"; } } if (line.hasOption("t")) { triggerTrimColumn = line.getOptionValue("t"); } if (line.hasOption("m")) { triggerMeasureColumn = line.getOptionValue("m"); } if (line.hasOption("x")) { trimColumnsString = line.getOptionValue("x"); } if (line.hasOption("r")) { trimRelativeColumn = line.getOptionValue("r"); } if (line.hasOption("s")) { subtitleColumn = line.getOptionValue("s"); } if (line.hasOption("z")) { zip = true; } if (line.hasOption("u")) { dutSelectionString = line.getOptionValue("u"); } if (line.hasOption("f")) { dutOffsetString = line.getOptionValue("f"); } String[] tC = trimColumnsString.split(","); VArrayList<String> trimColumns = new VArrayList<String>(); for (String s : tC) { trimColumns.add(s); } String[] dS = dutSelectionString.split("-"); if (dS.length < 2) throw new Exception("dut specification is wrong, should be e.g. 1-16"); int dutStart = Integer.parseInt(dS[0]); int dutStop = Integer.parseInt(dS[1]); int dutOffset = Integer.parseInt(dutOffsetString); merge(dclogFiles, combinationsFile, outputFile, zip, triggerTrimColumn, trimRelativeColumn, trimAbsColumn, trimColumns, triggerMeasureColumn, subtitleColumn, dutStart, dutStop, dutOffset); } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(Info.getVersionString("MergeResults"), options); } catch (Exception e) { System.out.println("MergeResults error: " + e); e.printStackTrace(); } }
From source file:org.duracloud.common.util.ApplicationConfig.java
public static Properties getPropsFromXmlStream(InputStream propsXmlStream) { Properties props = new Properties(); try {/*ww w. j a v a2 s .c o m*/ props.loadFromXML(propsXmlStream); } catch (InvalidPropertiesFormatException e) { log.error(e.getMessage()); log.error(ExceptionUtil.getStackTraceAsString(e)); throw new RuntimeException(e); } catch (IOException e) { log.error(e.getMessage()); log.error(ExceptionUtil.getStackTraceAsString(e)); throw new RuntimeException(e); } finally { if (propsXmlStream != null) { try { propsXmlStream.close(); } catch (IOException e) { String error = "Error closing properties stream: " + e.getMessage(); throw new RuntimeException(error, e); } } } return props; }
From source file:eu.eidas.configuration.ConfigurationCreator.java
/** * Gets the new instance.// www . ja v a 2s .com * * @param fileName the file name * * @return the properties from the new instance * * @throws EIDASSAMLEngineException the EIDASSAML engine * runtime exception */ private static Properties getNewInstance(final String fileName) throws EIDASSAMLEngineException { LOGGER.info("Create configuration properties to Eidas Saml Engine from file=" + fileName); if (fileName == null) { LOGGER.error("Error file null "); throw new EIDASSAMLEngineException(EIDASErrors.SAML_ENGINE_CONFIGURATION_ERROR.errorCode(), EIDASErrors.SAML_ENGINE_CONFIGURATION_ERROR.errorMessage(), new Exception("Fichier null")); } InputStream fileEngineProp = null; try { fileEngineProp = ConfigurationCreator.class.getResourceAsStream("/" + fileName); final Properties configuration = new Properties(); configuration.loadFromXML(fileEngineProp); return configuration; } catch (InvalidPropertiesFormatException e) { LOGGER.warn("Invalid properties format."); throw new EIDASSAMLEngineException(EIDASErrors.SAML_ENGINE_CONFIGURATION_ERROR.errorCode(), EIDASErrors.SAML_ENGINE_CONFIGURATION_ERROR.errorMessage(), e); } catch (IOException e) { LOGGER.error("Error read file: " + fileName); throw new EIDASSAMLEngineException(EIDASErrors.SAML_ENGINE_CONFIGURATION_ERROR.errorCode(), EIDASErrors.SAML_ENGINE_CONFIGURATION_ERROR.errorMessage(), e); } catch (Exception e) { LOGGER.error("Exception read file: " + fileName); throw new EIDASSAMLEngineException(EIDASErrors.SAML_ENGINE_CONFIGURATION_ERROR.errorCode(), EIDASErrors.SAML_ENGINE_CONFIGURATION_ERROR.errorMessage(), e); } finally { IOUtils.closeQuietly(fileEngineProp); } }
From source file:eu.stork.peps.configuration.ConfigurationCreator.java
/** * Gets the new instance./* w w w .java2 s.c o m*/ * * @param fileName the file name * @return the properties from the new instance * @throws STORKSAMLEngineException the STORKSAML engine * runtime exception */ private static Properties getNewInstance(final String fileName) throws STORKSAMLEngineException { InputStream fileEngineProp = null; // fetch base from system properties, give a default if there is nothing configured String base = System.getProperty("eu.stork.samlengine.config.location"); if (null != base) { if (!base.endsWith("/")) { base += "/"; } } else { base = "/"; } LOGGER.info("Create file configuration properties to Stork Saml Engine: " + base + fileName); try { if (null != base) fileEngineProp = new FileInputStream(base + fileName); else fileEngineProp = ConfigurationCreator.class.getResourceAsStream(base + fileName); final Properties configuration = new Properties(); configuration.loadFromXML(fileEngineProp); return configuration; } catch (InvalidPropertiesFormatException e) { LOGGER.error("Invalid properties format."); throw new STORKSAMLEngineException(e); } catch (IOException e) { LOGGER.error("Error read file: " + base + fileName); throw new STORKSAMLEngineException(e); } finally { IOUtils.closeQuietly(fileEngineProp); } }