From f25eced9fe3841b01af507002d6e9e64ea5ff14c Mon Sep 17 00:00:00 2001 From: Bigeon Emmanuel Date: Wed, 14 Feb 2024 14:55:23 +0100 Subject: [PATCH] [refactor] Remove duplications --- src/main/java/fr/u_paris/gla/project/App.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/u_paris/gla/project/App.java b/src/main/java/fr/u_paris/gla/project/App.java index 47d9a85..811ed94 100644 --- a/src/main/java/fr/u_paris/gla/project/App.java +++ b/src/main/java/fr/u_paris/gla/project/App.java @@ -65,26 +65,26 @@ public class App { /** @param out */ public static void printAppInfos(PrintStream out) { - Properties props = new Properties(); - try (InputStream is = App.class.getResourceAsStream("application.properties")) { //$NON-NLS-1$ - props.load(is); - } catch (IOException e) { - throw new RuntimeException("Unable to read application informations", e); //$NON-NLS-1$ - } + Properties props = readApplicationProperties(); out.println("Application: " + props.getProperty("app.name", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ out.println("Version: " + props.getProperty("app.version", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ out.println("By: " + props.getProperty("app.team", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ } - /** Shows the logo in an image. */ - public static void showLogo() { + private static Properties readApplicationProperties() { Properties props = new Properties(); try (InputStream is = App.class.getResourceAsStream("application.properties")) { //$NON-NLS-1$ props.load(is); } catch (IOException e) { throw new RuntimeException("Unable to read application informations", e); //$NON-NLS-1$ } + return props; + } + + /** Shows the logo in an image. */ + public static void showLogo() { + Properties props = readApplicationProperties(); JFrame frame = new JFrame(props.getProperty("app.name")); //$NON-NLS-1$ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);