Skip to content
Snippets Groups Projects
Commit 494ae8b2 authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Feature points import/export service made static; Inappropriate Optimal return value changed

parent c0b5f22c
No related branches found
No related tags found
No related merge requests found
......@@ -15,14 +15,11 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
......@@ -36,7 +33,7 @@ public class FeaturePointImportExportService {
private static final String COLUMN_DELIMETER = ",";
private static final String CODE_PREFIX_DELIMETER = " ";
public Optional<List<FeaturePoint>> importFeaturePoints(String path, String fileName) {
public static List<FeaturePoint> importFeaturePoints(String path, String fileName) {
FileResourcesUtils app = new FileResourcesUtils();
try (InputStreamReader streamReader
= new InputStreamReader(app.getFileAsStream(path, fileName), StandardCharsets.UTF_8);
......@@ -66,7 +63,7 @@ public class FeaturePointImportExportService {
);
points.add(point);
}
return Optional.of(points);
return points;
} catch (IOException e) {
throw new FeaturePointException(String.format("Feature point cannot open file", fileName));
......@@ -75,11 +72,11 @@ public class FeaturePointImportExportService {
}
}
private String getCode(String str) {
private static String getCode(String str) {
return str.substring(0, str.indexOf(CODE_PREFIX_DELIMETER));
}
public void exportFeaturePoints(List<FeaturePoint> featurePointList, String objectName) throws FileNotFoundException, IOException {
public static void exportFeaturePoints(List<FeaturePoint> featurePointList, String objectName) throws FileNotFoundException, IOException {
File csvOutputFile = new File(String.format("%s_landmarks.csv", objectName));
// CSV is a normal text file, need a writer
try (BufferedWriter bw = new BufferedWriter(new FileWriter(csvOutputFile))) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment