-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove usage of deprecated GUtil; move to own PropertiesUtil class
- Loading branch information
1 parent
ddf5b58
commit a147c1b
Showing
3 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/eu/xenit/gradle/alfrescosdk/internal/PropertiesUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package eu.xenit.gradle.alfrescosdk.internal; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
import org.gradle.api.UncheckedIOException; | ||
|
||
public final class PropertiesUtil { | ||
private PropertiesUtil() { | ||
throw new UnsupportedOperationException("This utility class can not be instantiated"); | ||
} | ||
|
||
public static Properties loadProperties(File propertyFile) { | ||
try { | ||
try(FileInputStream inputStream = new FileInputStream(propertyFile)) { | ||
return loadProperties(inputStream); | ||
} | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
} | ||
|
||
private static Properties loadProperties(InputStream inputStream) { | ||
Properties properties = new Properties(); | ||
try { | ||
properties.load(inputStream); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
return properties; | ||
} | ||
|
||
public static void saveProperties(Properties properties, File propertyFile) { | ||
try { | ||
try (FileOutputStream propertiesFileOutputStream = new FileOutputStream(propertyFile)) { | ||
properties.store(propertiesFileOutputStream, null); | ||
} | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters