import java.io.File;
import java.io.RandomAccessFile;
import java.io.IOException;

public class LogFileHolder {
    public static void main(String[] args) {
        File logFile = new File("log_0.log");

        // Wait until log_0.log exists
        while (!logFile.exists()) {
            System.out.println("⏳ Waiting for log_0.log to be created...");
            try {
                Thread.sleep(500); // check every 500ms
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        // Hold file open for 15 seconds
        try (RandomAccessFile raf = new RandomAccessFile(logFile, "r")) {
            System.out.println("✅ Holding log_0.log for 15 seconds...");
            Thread.sleep(15000);
            System.out.println("✅ Done holding log_0.log.");
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}

