Read files from a nested folder in a jar
up vote
0
down vote
favorite
In my spring-boot web app I have the following structure:
- resources
- properties
- profiles
- profile1.properties
- profile2.properties
- profile3.properties
I would like to read all the properties from all the files under the profiles folder. The solution should work for all of the following:
- Running from an IDE
- Running from a jar
- Running on a windows server
- Running on a linux server
I've encountered a few solution proposals but couldn't actually find one that works.
spring-boot executable-jar properties-file
add a comment |
up vote
0
down vote
favorite
In my spring-boot web app I have the following structure:
- resources
- properties
- profiles
- profile1.properties
- profile2.properties
- profile3.properties
I would like to read all the properties from all the files under the profiles folder. The solution should work for all of the following:
- Running from an IDE
- Running from a jar
- Running on a windows server
- Running on a linux server
I've encountered a few solution proposals but couldn't actually find one that works.
spring-boot executable-jar properties-file
Q: What "solution proposals"? Did they involve .getResourceAsStream()? What problem(s)/limitation(s) did you encounter?
– paulsm4
Nov 21 at 20:11
Use Spring resource loading and useclasspath:profiles/profile1.properties
to load it.
– M. Deinum
Nov 21 at 20:25
@Denium the file names are unknown, I only know the the location of the profiles folder.
– forhas
Nov 21 at 20:31
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In my spring-boot web app I have the following structure:
- resources
- properties
- profiles
- profile1.properties
- profile2.properties
- profile3.properties
I would like to read all the properties from all the files under the profiles folder. The solution should work for all of the following:
- Running from an IDE
- Running from a jar
- Running on a windows server
- Running on a linux server
I've encountered a few solution proposals but couldn't actually find one that works.
spring-boot executable-jar properties-file
In my spring-boot web app I have the following structure:
- resources
- properties
- profiles
- profile1.properties
- profile2.properties
- profile3.properties
I would like to read all the properties from all the files under the profiles folder. The solution should work for all of the following:
- Running from an IDE
- Running from a jar
- Running on a windows server
- Running on a linux server
I've encountered a few solution proposals but couldn't actually find one that works.
spring-boot executable-jar properties-file
spring-boot executable-jar properties-file
edited yesterday
asked Nov 21 at 20:07
forhas
4,991135187
4,991135187
Q: What "solution proposals"? Did they involve .getResourceAsStream()? What problem(s)/limitation(s) did you encounter?
– paulsm4
Nov 21 at 20:11
Use Spring resource loading and useclasspath:profiles/profile1.properties
to load it.
– M. Deinum
Nov 21 at 20:25
@Denium the file names are unknown, I only know the the location of the profiles folder.
– forhas
Nov 21 at 20:31
add a comment |
Q: What "solution proposals"? Did they involve .getResourceAsStream()? What problem(s)/limitation(s) did you encounter?
– paulsm4
Nov 21 at 20:11
Use Spring resource loading and useclasspath:profiles/profile1.properties
to load it.
– M. Deinum
Nov 21 at 20:25
@Denium the file names are unknown, I only know the the location of the profiles folder.
– forhas
Nov 21 at 20:31
Q: What "solution proposals"? Did they involve .getResourceAsStream()? What problem(s)/limitation(s) did you encounter?
– paulsm4
Nov 21 at 20:11
Q: What "solution proposals"? Did they involve .getResourceAsStream()? What problem(s)/limitation(s) did you encounter?
– paulsm4
Nov 21 at 20:11
Use Spring resource loading and use
classpath:profiles/profile1.properties
to load it.– M. Deinum
Nov 21 at 20:25
Use Spring resource loading and use
classpath:profiles/profile1.properties
to load it.– M. Deinum
Nov 21 at 20:25
@Denium the file names are unknown, I only know the the location of the profiles folder.
– forhas
Nov 21 at 20:31
@Denium the file names are unknown, I only know the the location of the profiles folder.
– forhas
Nov 21 at 20:31
add a comment |
1 Answer
1
active
oldest
votes
up vote
-1
down vote
accepted
Based on a technical article written by Greg Briggs,
this is the solution I've written:
/**
* Loads all properties files under the given path, assuming it's under the classpath.
*
* @param clazz Any class that lives in the same place as the resources you want.
* @param parentFolderPath The profiles folder path, relative to the classpath.
* Should end with "/", but not start with one.
* Example: "properties/profiles/
* @return A set of all PropertyFile that represents all the properties files under the given path
* @throws IOException
*/
public static Set<PropertyFile> getPropertiesFromPath(Class<?> clazz, String parentFolderPath) throws IOException {
if (!parentFolderPath.endsWith("/")) {
throw new InvalidPathException(parentFolderPath, "Path must end with '/'");
}
Set<PropertyFile> retVal = Sets.newHashSet();
URL dirURL = clazz.getClassLoader().getResource(parentFolderPath);
if (dirURL != null && dirURL.getProtocol().equals("file")) { //IDE CASE
Resource profilesFolderResource = new ClassPathResource(parentFolderPath);
File profilesFolder = profilesFolderResource.getFile();
for (File propertiesFile : profilesFolder.listFiles()) {
Properties props = new Properties();
try (InputStream is = FileUtils.openInputStream(propertiesFile)) {
props.load(is);
PropertyFile propertyFile = new PropertyFile(propertiesFile.getName(), propertiesFile.getAbsolutePath(), props);
retVal.add(propertyFile);
}
}
return retVal;
} else if (dirURL.getProtocol().equals("jar")) { // A JAR PATH
String jarPath = getJarPathFromURL(dirURL); //strip out only the JAR file
JarFile jar = new JarFile(URLDecoder.decode(jarPath, Charsets.UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
while (entries.hasMoreElements()) {
JarEntry jEntry = entries.nextElement();
String name = jEntry.getName();
if (isProfileFile(jEntry, parentFolderPath)) { //filter according to the path
Path pathOfFile = Paths.get(name);
String fileName = pathOfFile.toString().substring(pathOfFile.toString().lastIndexOf(File.separator) + 1);
Properties props = new Properties();
try (InputStream stream = jar.getInputStream(jEntry)) {
props.load(stream);
PropertyFile propertyFile = new PropertyFile(fileName, pathOfFile.toString(), props);
retVal.add(propertyFile);
}
}
}
return retVal;
}
throw new UnsupportedOperationException("Cannot list files for URL " + dirURL);
}
/**
* @param jarEntry
* @param parentFolderPath
* @return true if the file represented by the JarEntry
* is a properties file under the given parentFolderPath folder, else false
*/
private static boolean isProfileFile(JarEntry jarEntry, String parentFolderPath) {
boolean result = false;
String name = jarEntry.getName();
if (name.endsWith(PROPERTIES_SUFFIX)) {
Path pathOfFile = Paths.get(name);
Path pathOfParent = Paths.get(parentFolderPath);
String folderPath = pathOfFile.toString().substring(0, pathOfFile.toString().lastIndexOf(File.separator));
if (folderPath.endsWith(pathOfParent.toString())) {
result = true;
}
}
return result;
}
private static String getJarPathFromURL(URL dirURL) {
OSUtil.OS os = OSUtil.getOS();
//strip out only the JAR file
String jarPath = OSUtil.OS.WINDOWS == os ? dirURL.getPath().substring(6, dirURL.getPath().indexOf("!")) :
dirURL.getPath().substring(5, dirURL.getPath().indexOf("!"));
return jarPath;
}
public static class PropertyFile {
public String fileName;
public String filePath;
public Properties properties;
public PropertyFile(String fileName, String filePath, Properties properties) {
this.fileName = fileName;
this.filePath = filePath;
this.properties = properties;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PropertyFile)) return false;
PropertyFile that = (PropertyFile) o;
return Objects.equals(filePath, that.filePath);
}
@Override
public int hashCode() {
return Objects.hash(filePath);
}
@Override
public String toString() {
return "PropertyFile{" +
"fileName='" + fileName + ''' +
", filePath='" + filePath + ''' +
", properties=" + properties +
'}';
}
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-1
down vote
accepted
Based on a technical article written by Greg Briggs,
this is the solution I've written:
/**
* Loads all properties files under the given path, assuming it's under the classpath.
*
* @param clazz Any class that lives in the same place as the resources you want.
* @param parentFolderPath The profiles folder path, relative to the classpath.
* Should end with "/", but not start with one.
* Example: "properties/profiles/
* @return A set of all PropertyFile that represents all the properties files under the given path
* @throws IOException
*/
public static Set<PropertyFile> getPropertiesFromPath(Class<?> clazz, String parentFolderPath) throws IOException {
if (!parentFolderPath.endsWith("/")) {
throw new InvalidPathException(parentFolderPath, "Path must end with '/'");
}
Set<PropertyFile> retVal = Sets.newHashSet();
URL dirURL = clazz.getClassLoader().getResource(parentFolderPath);
if (dirURL != null && dirURL.getProtocol().equals("file")) { //IDE CASE
Resource profilesFolderResource = new ClassPathResource(parentFolderPath);
File profilesFolder = profilesFolderResource.getFile();
for (File propertiesFile : profilesFolder.listFiles()) {
Properties props = new Properties();
try (InputStream is = FileUtils.openInputStream(propertiesFile)) {
props.load(is);
PropertyFile propertyFile = new PropertyFile(propertiesFile.getName(), propertiesFile.getAbsolutePath(), props);
retVal.add(propertyFile);
}
}
return retVal;
} else if (dirURL.getProtocol().equals("jar")) { // A JAR PATH
String jarPath = getJarPathFromURL(dirURL); //strip out only the JAR file
JarFile jar = new JarFile(URLDecoder.decode(jarPath, Charsets.UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
while (entries.hasMoreElements()) {
JarEntry jEntry = entries.nextElement();
String name = jEntry.getName();
if (isProfileFile(jEntry, parentFolderPath)) { //filter according to the path
Path pathOfFile = Paths.get(name);
String fileName = pathOfFile.toString().substring(pathOfFile.toString().lastIndexOf(File.separator) + 1);
Properties props = new Properties();
try (InputStream stream = jar.getInputStream(jEntry)) {
props.load(stream);
PropertyFile propertyFile = new PropertyFile(fileName, pathOfFile.toString(), props);
retVal.add(propertyFile);
}
}
}
return retVal;
}
throw new UnsupportedOperationException("Cannot list files for URL " + dirURL);
}
/**
* @param jarEntry
* @param parentFolderPath
* @return true if the file represented by the JarEntry
* is a properties file under the given parentFolderPath folder, else false
*/
private static boolean isProfileFile(JarEntry jarEntry, String parentFolderPath) {
boolean result = false;
String name = jarEntry.getName();
if (name.endsWith(PROPERTIES_SUFFIX)) {
Path pathOfFile = Paths.get(name);
Path pathOfParent = Paths.get(parentFolderPath);
String folderPath = pathOfFile.toString().substring(0, pathOfFile.toString().lastIndexOf(File.separator));
if (folderPath.endsWith(pathOfParent.toString())) {
result = true;
}
}
return result;
}
private static String getJarPathFromURL(URL dirURL) {
OSUtil.OS os = OSUtil.getOS();
//strip out only the JAR file
String jarPath = OSUtil.OS.WINDOWS == os ? dirURL.getPath().substring(6, dirURL.getPath().indexOf("!")) :
dirURL.getPath().substring(5, dirURL.getPath().indexOf("!"));
return jarPath;
}
public static class PropertyFile {
public String fileName;
public String filePath;
public Properties properties;
public PropertyFile(String fileName, String filePath, Properties properties) {
this.fileName = fileName;
this.filePath = filePath;
this.properties = properties;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PropertyFile)) return false;
PropertyFile that = (PropertyFile) o;
return Objects.equals(filePath, that.filePath);
}
@Override
public int hashCode() {
return Objects.hash(filePath);
}
@Override
public String toString() {
return "PropertyFile{" +
"fileName='" + fileName + ''' +
", filePath='" + filePath + ''' +
", properties=" + properties +
'}';
}
}
add a comment |
up vote
-1
down vote
accepted
Based on a technical article written by Greg Briggs,
this is the solution I've written:
/**
* Loads all properties files under the given path, assuming it's under the classpath.
*
* @param clazz Any class that lives in the same place as the resources you want.
* @param parentFolderPath The profiles folder path, relative to the classpath.
* Should end with "/", but not start with one.
* Example: "properties/profiles/
* @return A set of all PropertyFile that represents all the properties files under the given path
* @throws IOException
*/
public static Set<PropertyFile> getPropertiesFromPath(Class<?> clazz, String parentFolderPath) throws IOException {
if (!parentFolderPath.endsWith("/")) {
throw new InvalidPathException(parentFolderPath, "Path must end with '/'");
}
Set<PropertyFile> retVal = Sets.newHashSet();
URL dirURL = clazz.getClassLoader().getResource(parentFolderPath);
if (dirURL != null && dirURL.getProtocol().equals("file")) { //IDE CASE
Resource profilesFolderResource = new ClassPathResource(parentFolderPath);
File profilesFolder = profilesFolderResource.getFile();
for (File propertiesFile : profilesFolder.listFiles()) {
Properties props = new Properties();
try (InputStream is = FileUtils.openInputStream(propertiesFile)) {
props.load(is);
PropertyFile propertyFile = new PropertyFile(propertiesFile.getName(), propertiesFile.getAbsolutePath(), props);
retVal.add(propertyFile);
}
}
return retVal;
} else if (dirURL.getProtocol().equals("jar")) { // A JAR PATH
String jarPath = getJarPathFromURL(dirURL); //strip out only the JAR file
JarFile jar = new JarFile(URLDecoder.decode(jarPath, Charsets.UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
while (entries.hasMoreElements()) {
JarEntry jEntry = entries.nextElement();
String name = jEntry.getName();
if (isProfileFile(jEntry, parentFolderPath)) { //filter according to the path
Path pathOfFile = Paths.get(name);
String fileName = pathOfFile.toString().substring(pathOfFile.toString().lastIndexOf(File.separator) + 1);
Properties props = new Properties();
try (InputStream stream = jar.getInputStream(jEntry)) {
props.load(stream);
PropertyFile propertyFile = new PropertyFile(fileName, pathOfFile.toString(), props);
retVal.add(propertyFile);
}
}
}
return retVal;
}
throw new UnsupportedOperationException("Cannot list files for URL " + dirURL);
}
/**
* @param jarEntry
* @param parentFolderPath
* @return true if the file represented by the JarEntry
* is a properties file under the given parentFolderPath folder, else false
*/
private static boolean isProfileFile(JarEntry jarEntry, String parentFolderPath) {
boolean result = false;
String name = jarEntry.getName();
if (name.endsWith(PROPERTIES_SUFFIX)) {
Path pathOfFile = Paths.get(name);
Path pathOfParent = Paths.get(parentFolderPath);
String folderPath = pathOfFile.toString().substring(0, pathOfFile.toString().lastIndexOf(File.separator));
if (folderPath.endsWith(pathOfParent.toString())) {
result = true;
}
}
return result;
}
private static String getJarPathFromURL(URL dirURL) {
OSUtil.OS os = OSUtil.getOS();
//strip out only the JAR file
String jarPath = OSUtil.OS.WINDOWS == os ? dirURL.getPath().substring(6, dirURL.getPath().indexOf("!")) :
dirURL.getPath().substring(5, dirURL.getPath().indexOf("!"));
return jarPath;
}
public static class PropertyFile {
public String fileName;
public String filePath;
public Properties properties;
public PropertyFile(String fileName, String filePath, Properties properties) {
this.fileName = fileName;
this.filePath = filePath;
this.properties = properties;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PropertyFile)) return false;
PropertyFile that = (PropertyFile) o;
return Objects.equals(filePath, that.filePath);
}
@Override
public int hashCode() {
return Objects.hash(filePath);
}
@Override
public String toString() {
return "PropertyFile{" +
"fileName='" + fileName + ''' +
", filePath='" + filePath + ''' +
", properties=" + properties +
'}';
}
}
add a comment |
up vote
-1
down vote
accepted
up vote
-1
down vote
accepted
Based on a technical article written by Greg Briggs,
this is the solution I've written:
/**
* Loads all properties files under the given path, assuming it's under the classpath.
*
* @param clazz Any class that lives in the same place as the resources you want.
* @param parentFolderPath The profiles folder path, relative to the classpath.
* Should end with "/", but not start with one.
* Example: "properties/profiles/
* @return A set of all PropertyFile that represents all the properties files under the given path
* @throws IOException
*/
public static Set<PropertyFile> getPropertiesFromPath(Class<?> clazz, String parentFolderPath) throws IOException {
if (!parentFolderPath.endsWith("/")) {
throw new InvalidPathException(parentFolderPath, "Path must end with '/'");
}
Set<PropertyFile> retVal = Sets.newHashSet();
URL dirURL = clazz.getClassLoader().getResource(parentFolderPath);
if (dirURL != null && dirURL.getProtocol().equals("file")) { //IDE CASE
Resource profilesFolderResource = new ClassPathResource(parentFolderPath);
File profilesFolder = profilesFolderResource.getFile();
for (File propertiesFile : profilesFolder.listFiles()) {
Properties props = new Properties();
try (InputStream is = FileUtils.openInputStream(propertiesFile)) {
props.load(is);
PropertyFile propertyFile = new PropertyFile(propertiesFile.getName(), propertiesFile.getAbsolutePath(), props);
retVal.add(propertyFile);
}
}
return retVal;
} else if (dirURL.getProtocol().equals("jar")) { // A JAR PATH
String jarPath = getJarPathFromURL(dirURL); //strip out only the JAR file
JarFile jar = new JarFile(URLDecoder.decode(jarPath, Charsets.UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
while (entries.hasMoreElements()) {
JarEntry jEntry = entries.nextElement();
String name = jEntry.getName();
if (isProfileFile(jEntry, parentFolderPath)) { //filter according to the path
Path pathOfFile = Paths.get(name);
String fileName = pathOfFile.toString().substring(pathOfFile.toString().lastIndexOf(File.separator) + 1);
Properties props = new Properties();
try (InputStream stream = jar.getInputStream(jEntry)) {
props.load(stream);
PropertyFile propertyFile = new PropertyFile(fileName, pathOfFile.toString(), props);
retVal.add(propertyFile);
}
}
}
return retVal;
}
throw new UnsupportedOperationException("Cannot list files for URL " + dirURL);
}
/**
* @param jarEntry
* @param parentFolderPath
* @return true if the file represented by the JarEntry
* is a properties file under the given parentFolderPath folder, else false
*/
private static boolean isProfileFile(JarEntry jarEntry, String parentFolderPath) {
boolean result = false;
String name = jarEntry.getName();
if (name.endsWith(PROPERTIES_SUFFIX)) {
Path pathOfFile = Paths.get(name);
Path pathOfParent = Paths.get(parentFolderPath);
String folderPath = pathOfFile.toString().substring(0, pathOfFile.toString().lastIndexOf(File.separator));
if (folderPath.endsWith(pathOfParent.toString())) {
result = true;
}
}
return result;
}
private static String getJarPathFromURL(URL dirURL) {
OSUtil.OS os = OSUtil.getOS();
//strip out only the JAR file
String jarPath = OSUtil.OS.WINDOWS == os ? dirURL.getPath().substring(6, dirURL.getPath().indexOf("!")) :
dirURL.getPath().substring(5, dirURL.getPath().indexOf("!"));
return jarPath;
}
public static class PropertyFile {
public String fileName;
public String filePath;
public Properties properties;
public PropertyFile(String fileName, String filePath, Properties properties) {
this.fileName = fileName;
this.filePath = filePath;
this.properties = properties;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PropertyFile)) return false;
PropertyFile that = (PropertyFile) o;
return Objects.equals(filePath, that.filePath);
}
@Override
public int hashCode() {
return Objects.hash(filePath);
}
@Override
public String toString() {
return "PropertyFile{" +
"fileName='" + fileName + ''' +
", filePath='" + filePath + ''' +
", properties=" + properties +
'}';
}
}
Based on a technical article written by Greg Briggs,
this is the solution I've written:
/**
* Loads all properties files under the given path, assuming it's under the classpath.
*
* @param clazz Any class that lives in the same place as the resources you want.
* @param parentFolderPath The profiles folder path, relative to the classpath.
* Should end with "/", but not start with one.
* Example: "properties/profiles/
* @return A set of all PropertyFile that represents all the properties files under the given path
* @throws IOException
*/
public static Set<PropertyFile> getPropertiesFromPath(Class<?> clazz, String parentFolderPath) throws IOException {
if (!parentFolderPath.endsWith("/")) {
throw new InvalidPathException(parentFolderPath, "Path must end with '/'");
}
Set<PropertyFile> retVal = Sets.newHashSet();
URL dirURL = clazz.getClassLoader().getResource(parentFolderPath);
if (dirURL != null && dirURL.getProtocol().equals("file")) { //IDE CASE
Resource profilesFolderResource = new ClassPathResource(parentFolderPath);
File profilesFolder = profilesFolderResource.getFile();
for (File propertiesFile : profilesFolder.listFiles()) {
Properties props = new Properties();
try (InputStream is = FileUtils.openInputStream(propertiesFile)) {
props.load(is);
PropertyFile propertyFile = new PropertyFile(propertiesFile.getName(), propertiesFile.getAbsolutePath(), props);
retVal.add(propertyFile);
}
}
return retVal;
} else if (dirURL.getProtocol().equals("jar")) { // A JAR PATH
String jarPath = getJarPathFromURL(dirURL); //strip out only the JAR file
JarFile jar = new JarFile(URLDecoder.decode(jarPath, Charsets.UTF_8.name()));
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
while (entries.hasMoreElements()) {
JarEntry jEntry = entries.nextElement();
String name = jEntry.getName();
if (isProfileFile(jEntry, parentFolderPath)) { //filter according to the path
Path pathOfFile = Paths.get(name);
String fileName = pathOfFile.toString().substring(pathOfFile.toString().lastIndexOf(File.separator) + 1);
Properties props = new Properties();
try (InputStream stream = jar.getInputStream(jEntry)) {
props.load(stream);
PropertyFile propertyFile = new PropertyFile(fileName, pathOfFile.toString(), props);
retVal.add(propertyFile);
}
}
}
return retVal;
}
throw new UnsupportedOperationException("Cannot list files for URL " + dirURL);
}
/**
* @param jarEntry
* @param parentFolderPath
* @return true if the file represented by the JarEntry
* is a properties file under the given parentFolderPath folder, else false
*/
private static boolean isProfileFile(JarEntry jarEntry, String parentFolderPath) {
boolean result = false;
String name = jarEntry.getName();
if (name.endsWith(PROPERTIES_SUFFIX)) {
Path pathOfFile = Paths.get(name);
Path pathOfParent = Paths.get(parentFolderPath);
String folderPath = pathOfFile.toString().substring(0, pathOfFile.toString().lastIndexOf(File.separator));
if (folderPath.endsWith(pathOfParent.toString())) {
result = true;
}
}
return result;
}
private static String getJarPathFromURL(URL dirURL) {
OSUtil.OS os = OSUtil.getOS();
//strip out only the JAR file
String jarPath = OSUtil.OS.WINDOWS == os ? dirURL.getPath().substring(6, dirURL.getPath().indexOf("!")) :
dirURL.getPath().substring(5, dirURL.getPath().indexOf("!"));
return jarPath;
}
public static class PropertyFile {
public String fileName;
public String filePath;
public Properties properties;
public PropertyFile(String fileName, String filePath, Properties properties) {
this.fileName = fileName;
this.filePath = filePath;
this.properties = properties;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PropertyFile)) return false;
PropertyFile that = (PropertyFile) o;
return Objects.equals(filePath, that.filePath);
}
@Override
public int hashCode() {
return Objects.hash(filePath);
}
@Override
public String toString() {
return "PropertyFile{" +
"fileName='" + fileName + ''' +
", filePath='" + filePath + ''' +
", properties=" + properties +
'}';
}
}
answered Nov 22 at 17:33
forhas
4,991135187
4,991135187
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419749%2fread-files-from-a-nested-folder-in-a-jar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Q: What "solution proposals"? Did they involve .getResourceAsStream()? What problem(s)/limitation(s) did you encounter?
– paulsm4
Nov 21 at 20:11
Use Spring resource loading and use
classpath:profiles/profile1.properties
to load it.– M. Deinum
Nov 21 at 20:25
@Denium the file names are unknown, I only know the the location of the profiles folder.
– forhas
Nov 21 at 20:31