Skip to content

Commit

Permalink
#21: Fixed encoding problem in translation statistics. ini file is no…
Browse files Browse the repository at this point in the history
…w UTF8
  • Loading branch information
k3b committed Oct 16, 2019
1 parent e397e7d commit e9e9647
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
15 changes: 4 additions & 11 deletions fotolib2/src/main/java/de/k3b/io/PhotoAutoprocessingDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
Expand Down Expand Up @@ -70,17 +69,11 @@ public PhotoAutoprocessingDto load(File outDir) throws IOException {
File apm = getApmFile();
properties.clear();
if (apm.exists() && apm.isFile() && apm.canRead()) {
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(apm);
properties.load(inputStream);
if (LibGlobal.debugEnabled) {
logger.debug(this.getClass().getSimpleName() + ": loaded from " + apm + ":" + this);
}
return this;
} finally {
FileUtils.close(inputStream,"PhotoAutoprocessingDto.load(" + apm + ")");
properties.load(apm);
if (LibGlobal.debugEnabled) {
logger.debug(this.getClass().getSimpleName() + ": loaded from " + apm + ":" + this);
}
return this;
}
return null;
}
Expand Down
13 changes: 13 additions & 0 deletions fotolib2/src/main/java/de/k3b/io/Properties.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.k3b.io;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -12,6 +14,17 @@ public class Properties extends java.util.Properties {

private static final String FILE_ENCODING = "UTF-8";

public synchronized void load(File file) throws IOException {
InputStream inputStream = null;

try {
inputStream = new FileInputStream(file);
load(inputStream);
} finally {
FileUtils.close(inputStream, file);
}
}

@Override
public synchronized void load(InputStream inputStream) throws IOException {
InputStreamReader in = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,14 @@ private static Document getXml(File file) {

public TranslationStatistics() {
Date fileLimitDate = null;
InputStream inputStream = null;

try {
inputStream = new FileInputStream(iniFile);
lastLocales.load(inputStream);
lastLocales.load(iniFile);

fileLimitDate = getModifyDateProperty("ignore");

readCountryTimeStatistics(country2History, gitFile);
} catch (IOException ex) {
} finally {
FileUtils.close(inputStream,"TranslationStatistics.load(" + iniFile + ")");
}
this.fileLimitDate = fileLimitDate;
}
Expand Down

0 comments on commit e9e9647

Please sign in to comment.