2024-09-21 16:50:53 +08:00
|
|
|
//import java.io.FileInputStream;
|
2023-11-02 22:02:39 +08:00
|
|
|
import java.io.FileOutputStream;
|
2024-09-21 16:50:53 +08:00
|
|
|
//import java.io.InputStreamReader;
|
2023-11-02 22:02:39 +08:00
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
2026-01-28 12:00:40 +08:00
|
|
|
import java.nio.file.Path;
|
|
|
|
|
import java.nio.file.Paths;
|
2023-11-02 22:02:39 +08:00
|
|
|
|
|
|
|
|
public class CommonHelper {
|
|
|
|
|
|
2026-01-28 12:00:40 +08:00
|
|
|
// =========== File Operations ===========
|
2023-11-02 22:02:39 +08:00
|
|
|
|
2026-01-28 12:00:40 +08:00
|
|
|
private static Path getRootDirectoryPath() throws Exception {
|
|
|
|
|
String rootDir = System.getenv("BMAP_BINDER_ROOT");
|
|
|
|
|
if (rootDir == null) {
|
|
|
|
|
throw new RuntimeException("Can not find essential environment variable BMAP_BINDER_ROOT");
|
|
|
|
|
} else {
|
|
|
|
|
return Paths.get(rootDir);
|
|
|
|
|
}
|
2023-11-02 22:02:39 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-28 12:00:40 +08:00
|
|
|
public static String getInputFilePath(String filename) throws Exception {
|
|
|
|
|
Path rootDir = getRootDirectoryPath();
|
|
|
|
|
Path filePath = rootDir.resolve("Extracted").resolve(filename);
|
|
|
|
|
return filePath.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getOutputFilePath(String filename) throws Exception {
|
|
|
|
|
Path rootDir = getRootDirectoryPath();
|
|
|
|
|
Path filePath = rootDir.resolve("Analyzed").resolve(filename);
|
|
|
|
|
return filePath.toString();
|
2023-11-02 22:02:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|