From b23925d78b0e21bcfb757bd14f1a3c43b5669f2d Mon Sep 17 00:00:00 2001 From: Lawan Samarasekara Date: Wed, 10 Apr 2024 01:35:35 +0530 Subject: [PATCH] Signed-off-by: Lawan Samarasekara --- .../divudi/bean/common/VersionController.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/divudi/bean/common/VersionController.java b/src/main/java/com/divudi/bean/common/VersionController.java index c40c1903ff..3c6cea1ffb 100644 --- a/src/main/java/com/divudi/bean/common/VersionController.java +++ b/src/main/java/com/divudi/bean/common/VersionController.java @@ -9,7 +9,6 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.io.IOException; -import java.nio.file.Path; /** @@ -21,27 +20,20 @@ public class VersionController { private final String fileName = "VERSION.txt"; - private String systemVersion = ""; // Public vareiable to store the system version read from the file + private String systemVersion; // Public vareiable to store the system version read from the file public VersionController() { - //readFirstLine(); // Load first line content upon bean instantiation + readFirstLine(); // Load first line content upon bean instantiation } /** * Reads the first line of the text file and checks if it contains the system version. */ public void readFirstLine() { + String filePath = "../".repeat(7) + fileName; try { - // Get the root directory of the application - Path rootDirectory = Paths.get("").toAbsolutePath(); - - // Construct the file path to VERSION.txt by navigating from the root directory - Path versionFilePath = rootDirectory.resolve(fileName); - - System.out.println("versionFilePath = " + versionFilePath); - // Read the first line from the file - String firstLine = Files.lines(versionFilePath).findFirst().orElse(null); + String firstLine = Files.lines(Paths.get(filePath)).findFirst().orElse(null); if (firstLine != null && !firstLine.isEmpty()) { // Set systemVersion to the content of the first line systemVersion = firstLine.trim();