Add basic exporter

This commit is contained in:
Bryden Basaran
2024-09-10 16:42:51 -04:00
parent 79f712469a
commit f0ca9edf13
5 changed files with 99 additions and 0 deletions
@@ -0,0 +1,33 @@
package org.misoenergy.hackday.kessel_run;
import java.io.File;
import java.io.IOException;
public class PCGenExporter {
public PCGenExporter() {
}
public void export(File file) {
try {
createOutputFile(file);
} catch (IOException e) {
handleFailedOutput(e);
}
}
private void createOutputFile(File file) throws IOException {
if (file.createNewFile()) {
System.out.println("File created: " + file.getName());
} else {
System.out.println("File already exists. Deleting and re-running");
file.delete();
createOutputFile(file);
}
}
private void handleFailedOutput(Exception e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}