mirror of
https://github.com/maxkratz/iflye.git
synced 2024-09-16 19:59:59 +00:00
Metrics CSV writer: create parent directory if it does not exist
This commit is contained in:
parent
0d72cdd5f6
commit
10ea05aace
2 changed files with 20 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -143,3 +143,5 @@ org.emoflon.gips.gipsl.examples.mdvne.seq/
|
|||
org.emoflon.gips.gipsl.examples.mdvne.bwignore/
|
||||
|
||||
vne.scenarios/model.xmi
|
||||
|
||||
vne.scenarios/metrics/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package scenario.util;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
@ -237,6 +238,23 @@ public class CsvUtil {
|
|||
return;
|
||||
}
|
||||
|
||||
if (format == null) {
|
||||
throw new IllegalArgumentException("Given CSV format was null");
|
||||
}
|
||||
|
||||
if (content == null || content.length == 0) {
|
||||
throw new IllegalArgumentException("Given content was null or empty.");
|
||||
}
|
||||
|
||||
// Create parent folder if it does not exist
|
||||
final int lastSlash = csvPath.lastIndexOf('/');
|
||||
final String parentPath = csvPath.substring(0, lastSlash);
|
||||
final File parentFolder = new File(parentPath);
|
||||
if (!parentFolder.exists()) {
|
||||
parentFolder.mkdir();
|
||||
}
|
||||
|
||||
// Write CSV line itself
|
||||
try {
|
||||
BufferedWriter out;
|
||||
// If file does not exist, write header to it
|
||||
|
|
Loading…
Reference in a new issue