Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- final Path lock = Files.write(PATH_TO_FILE_IN_A_CONSTANT, "Executing Job", StandardOpenOption.CREATE, StandardOpenOption.WRITE);
- final RandomAccessFile raf = new RandomAccessFile(lock.toFile(), "r");
- FileLock fl = new FileInputStream(raf.getFD()).getChannel().lock(0, Long.MAX_VALUE, true);
- } catch (final IOException e) {
- LOGGER.error("Error while trying to write file. ERROR: " + e.getMessage(), e);
- Runtime.getRuntime().exit(-1);
- }
Add Comment
Please, Sign In to add comment