Here you can find the source of loadProperties(JarFile enclosedJarFile, String jarEntryPath)
Parameter | Description |
---|---|
enclosedJarFile | the enclosed jar file |
jarEntryPath | the jar entry path |
Parameter | Description |
---|---|
IOException | This is a special case where we want the consumers tocontinue without failures, because most of the cases consumesthis in a loop. |
public static Properties loadProperties(JarFile enclosedJarFile, String jarEntryPath) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 *******************************************************************************/ import java.io.IOException; import java.io.InputStream; import java.util.Properties; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class Main { /**/* ww w. j a v a 2s .co m*/ * Loads the properties file residing inside a jar. The enclosed jar file is * queried for the given jar entry path and is parsed into a properties * file. Most of the cases this is being used to load some SOA properties * file from a jar project which is not imported to the workspace but is * stored somewhere in the file system. But any client who wants to load a * properties file can use this. There is nothing SOA specific here in this * API. * * @param enclosedJarFile the enclosed jar file * @param jarEntryPath the jar entry path * @return the properties * @throws IOException This is a special case where we want the consumers to * continue without failures, because most of the cases consumes * this in a loop. */ public static Properties loadProperties(JarFile enclosedJarFile, String jarEntryPath) throws IOException { JarEntry jarEntry = enclosedJarFile.getJarEntry(jarEntryPath); InputStream inputStream = enclosedJarFile.getInputStream(jarEntry); Properties properties = new Properties(); properties.load(inputStream); return properties; } }