Skip to content

Commit eb08b4c

Browse files
committed
Java properties file example
1 parent 66953be commit eb08b4c

File tree

12 files changed

+53
-1
lines changed

12 files changed

+53
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>com.hellokoding.java</groupId>
8-
<artifactId>collections</artifactId>
8+
<artifactId>java-collections</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010

1111
<properties>

java-examples/collections/src/main/java/com/hellokoding/java/collections/BlockingQueueExample.java renamed to java-examples/java-collections/src/main/java/com/hellokoding/java/collections/BlockingQueueExample.java

File renamed without changes.

java-examples/collections/src/main/java/com/hellokoding/java/collections/PriorityBlockingQueueExample.java renamed to java-examples/java-collections/src/main/java/com/hellokoding/java/collections/PriorityBlockingQueueExample.java

File renamed without changes.

java-examples/collections/src/main/java/com/hellokoding/java/collections/StringSortAscending.java renamed to java-examples/java-collections/src/main/java/com/hellokoding/java/collections/StringSortAscending.java

File renamed without changes.

java-examples/collections/src/main/java/com/hellokoding/java/collections/StringSortDescending.java renamed to java-examples/java-collections/src/main/java/com/hellokoding/java/collections/StringSortDescending.java

File renamed without changes.

java-examples/collections/src/main/java/com/hellokoding/java/collections/StringSortDescendingByStringBuilder.java renamed to java-examples/java-collections/src/main/java/com/hellokoding/java/collections/StringSortDescendingByStringBuilder.java

File renamed without changes.

java-examples/collections/src/test/java/com/hellokoding/java/collections/PriorityQueueTest.java renamed to java-examples/java-collections/src/test/java/com/hellokoding/java/collections/PriorityQueueTest.java

File renamed without changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
target
3+
*.iml
4+
out
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.hellokoding.util</groupId>
8+
<artifactId>properties-file-java</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<exec.mainClass>com.hellokoding.util.Main</exec.mainClass>
13+
</properties>
14+
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.hellokoding.util;
2+
3+
import java.io.FileInputStream;
4+
import java.io.IOException;
5+
import java.util.Properties;
6+
import java.util.logging.Level;
7+
import java.util.logging.Logger;
8+
9+
public enum ApplicationProperties {
10+
INSTANCE;
11+
12+
private final Properties properties;
13+
14+
ApplicationProperties() {
15+
properties = new Properties();
16+
try {
17+
properties.load(new FileInputStream("src/main/resources/application.properties"));
18+
} catch (IOException e) {
19+
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, e.getMessage(), e);
20+
}
21+
}
22+
23+
public String getAppName() {
24+
return properties.getProperty("app.name");
25+
}
26+
}

0 commit comments

Comments
 (0)