From 0c7b2f61dc6deba0fcaf002f802db5fdc49fd8f7 Mon Sep 17 00:00:00 2001 From: hxs Date: Thu, 28 Nov 2019 16:48:04 +0100 Subject: [PATCH] review --- jun/src/jun/Jun.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/jun/src/jun/Jun.java b/jun/src/jun/Jun.java index f1e8389..19c214a 100644 --- a/jun/src/jun/Jun.java +++ b/jun/src/jun/Jun.java @@ -6,6 +6,7 @@ import java.io.InputStreamReader; import java.io.RandomAccessFile; import java.lang.management.ManagementFactory; +import java.text.MessageFormat; import java.util.regex.Pattern; import exception.ApplicationException; @@ -92,10 +93,7 @@ public void unlock(String path) { public void forceLock(String path) throws IOException, FileLockException { unlock(path); File file = new File(path); - if (file.exists()) { - String msg = String.format("Unable to delete the lock file: '%s'", file.getAbsolutePath()); - throw new FileLockException(msg); - } + if (file.exists()) throw new FileLockException(MessageFormat.format("Unable to delete the lock file: '{0}'", file.getAbsolutePath())); file.createNewFile(); @@ -187,7 +185,7 @@ private boolean pidIsJavaRunning(String pid) throws SystemException { e1.printStackTrace(); } } - throw new SystemException(String.format("Error while searching PID.\n%s", e.getMessage())); + throw new SystemException(MessageFormat.format("Error while searching PID.\n{0}", e.getMessage())); } finally { if (br != null) { try {