diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/AffUtils.java b/app/src/main/java/de/k3b/android/androFotoFinder/AffUtils.java index 6fd6d512..e68386cb 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/AffUtils.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/AffUtils.java @@ -25,9 +25,9 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.Properties; import de.k3b.android.androFotoFinder.queries.FotoSql; +import de.k3b.io.Properties; import de.k3b.io.collections.SelectedFiles; import de.k3b.io.collections.SelectedItems; diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageContextController.java b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageContextController.java index 7ce0d7c8..d0d2ecdc 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageContextController.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageContextController.java @@ -27,19 +27,16 @@ import android.view.Menu; import android.view.MenuItem; -import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStreamReader; +import java.io.InputStream; import java.io.OutputStreamWriter; -import java.io.Reader; import java.io.Writer; import java.util.ArrayList; import java.util.List; -import java.util.Properties; import de.k3b.android.GuiUtil; import de.k3b.android.androFotoFinder.Global; @@ -49,6 +46,7 @@ import de.k3b.android.widget.Dialogs; import de.k3b.database.SqlTemplateEngine; import de.k3b.io.FileUtils; +import de.k3b.io.Properties; /** * #70: Handles optional extra context specific detail text that can be displayed in @@ -116,11 +114,11 @@ protected Properties loadFromFile() { File propFile = getPropertiesFile(); if (propFile.exists()) { - Reader br = null; + InputStream br = null; try { - br = new BufferedReader(new InputStreamReader(new FileInputStream(propFile), "UTF-8")); + br = new FileInputStream(propFile); properties.load(br); } catch (IOException ex) { diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/AndroidAlbumUtils.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/AndroidAlbumUtils.java index bd90c6e2..5a4e38f6 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/queries/AndroidAlbumUtils.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/AndroidAlbumUtils.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Properties; import de.k3b.android.androFotoFinder.Common; import de.k3b.android.androFotoFinder.GalleryFilterPathState; @@ -50,6 +49,7 @@ import de.k3b.io.FileUtils; import de.k3b.io.GalleryFilterParameter; import de.k3b.io.IGalleryFilter; +import de.k3b.io.Properties; import de.k3b.io.StringUtils; import de.k3b.tagDB.TagProcessor; diff --git a/fotolib2/src/main/java/de/k3b/io/PhotoAutoprocessingDto.java b/fotolib2/src/main/java/de/k3b/io/PhotoAutoprocessingDto.java index 955c1512..f373acfa 100644 --- a/fotolib2/src/main/java/de/k3b/io/PhotoAutoprocessingDto.java +++ b/fotolib2/src/main/java/de/k3b/io/PhotoAutoprocessingDto.java @@ -27,7 +27,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.Serializable; -import java.util.Properties; import de.k3b.LibGlobal; import de.k3b.media.IPhotoProperties; diff --git a/fotolib2/src/main/java/de/k3b/io/Properties.java b/fotolib2/src/main/java/de/k3b/io/Properties.java new file mode 100644 index 00000000..22bd339e --- /dev/null +++ b/fotolib2/src/main/java/de/k3b/io/Properties.java @@ -0,0 +1,35 @@ +package de.k3b.io; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; + +public class Properties extends java.util.Properties { + + private static final String FILE_ENCODING = "UTF-8"; + + @Override + public synchronized void load(InputStream inputStream) throws IOException { + InputStreamReader in = null; + try { + in = new InputStreamReader(inputStream, FILE_ENCODING); + load(in); + } finally { + FileUtils.close(in, inputStream); + } + } + + public void store(OutputStream stream, String comment) throws IOException { + Writer o = null; + try { + o = new BufferedWriter(new OutputStreamWriter(stream, FILE_ENCODING)); + store(o, comment); + } finally { + FileUtils.close(o, stream); + } + } +} diff --git a/fotolib2/src/main/java/de/k3b/zip/ZipConfigRepository.java b/fotolib2/src/main/java/de/k3b/zip/ZipConfigRepository.java index 33a32ba9..d43febf1 100644 --- a/fotolib2/src/main/java/de/k3b/zip/ZipConfigRepository.java +++ b/fotolib2/src/main/java/de/k3b/zip/ZipConfigRepository.java @@ -28,11 +28,11 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Date; -import java.util.Properties; import de.k3b.LibGlobal; import de.k3b.io.DateUtil; import de.k3b.io.FileUtils; +import de.k3b.io.Properties; import de.k3b.io.StringUtils; /** Parameters that define a backup that can be persisted through a properties-file */ diff --git a/fotolib2/src/test/java/de/k3b/io/FileCommandAutoIntegrationTests.java b/fotolib2/src/test/java/de/k3b/io/FileCommandAutoIntegrationTests.java index 41817628..ea839c8e 100644 --- a/fotolib2/src/test/java/de/k3b/io/FileCommandAutoIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/io/FileCommandAutoIntegrationTests.java @@ -29,7 +29,6 @@ import java.io.File; import java.io.IOException; import java.util.Date; -import java.util.Properties; import de.k3b.LibGlobal; import de.k3b.TestUtil; @@ -37,11 +36,11 @@ import de.k3b.media.ExifInterface; import de.k3b.media.ExifInterfaceEx; import de.k3b.media.IPhotoProperties; +import de.k3b.media.MediaFormatter.FieldID; import de.k3b.media.PhotoPropertiesBulkUpdateService; import de.k3b.media.PhotoPropertiesDTO; import de.k3b.media.PhotoPropertiesDiffCopy; import de.k3b.media.PhotoPropertiesFormatter; -import de.k3b.media.MediaFormatter.FieldID; import de.k3b.transactionlog.TransactionLoggerBase; /** diff --git a/fotolib2/src/test/java/de/k3b/translations/TranslationStatistics.java b/fotolib2/src/test/java/de/k3b/translations/TranslationStatistics.java index 1328a627..a37a69bc 100644 --- a/fotolib2/src/test/java/de/k3b/translations/TranslationStatistics.java +++ b/fotolib2/src/test/java/de/k3b/translations/TranslationStatistics.java @@ -28,13 +28,11 @@ import java.io.FileReader; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -48,6 +46,7 @@ import de.k3b.io.DateUtil; import de.k3b.io.FileUtils; import de.k3b.io.ListUtils; +import de.k3b.io.Properties; /** * Creates a translation statistics in Markdown-format for the app from @@ -247,10 +246,10 @@ private static Document getXml(File file) { public TranslationStatistics() { Date fileLimitDate = null; - InputStreamReader inputStream = null; + InputStream inputStream = null; try { - inputStream = new InputStreamReader(new FileInputStream(iniFile), "UTF-8"); + inputStream = new FileInputStream(iniFile); lastLocales.load(inputStream); fileLimitDate = getModifyDateProperty("ignore");