diff options
| author | Mavlushechka <mavlushechka@gmail.com> | 2022-01-30 18:33:06 +0500 | 
|---|---|---|
| committer | Mavlushechka <mavlushechka@gmail.com> | 2022-01-30 18:33:06 +0500 | 
| commit | 728c792aabb93a6a6ac5e8d8088f4adf920a4309 (patch) | |
| tree | e7ec9418e07478e7acf5181ec773fe43d232ee8e /src/main/java/com/mavlushechka/animarfo | |
| parent | 31bbf2e181dcdfcf26c9009b2779642b89b35bf2 (diff) | |
Move loadProperties method logic to static block
Diffstat (limited to 'src/main/java/com/mavlushechka/animarfo')
| -rw-r--r-- | src/main/java/com/mavlushechka/animarfo/App.java | 23 | 
1 files changed, 7 insertions, 16 deletions
| diff --git a/src/main/java/com/mavlushechka/animarfo/App.java b/src/main/java/com/mavlushechka/animarfo/App.java index 897f4d6..7c5baad 100644 --- a/src/main/java/com/mavlushechka/animarfo/App.java +++ b/src/main/java/com/mavlushechka/animarfo/App.java @@ -1,9 +1,7 @@  package com.mavlushechka.animarfo;  import com.mavlushechka.animarfo.telegram.bot.Bot; -import org.jetbrains.annotations.NotNull; -import java.io.File;  import java.io.FileInputStream;  import java.io.IOException;  import java.util.Properties; @@ -12,10 +10,16 @@ import java.util.logging.LogManager;  import java.util.logging.Logger;  public class App { -    public static final Properties PROPERTIES = loadProperties(new File("src/main/resources/app.properties")); +    public static final Properties PROPERTIES = new Properties();      private static final Logger LOGGER = Logger.getLogger(App.class.getName());      static { +        try (FileInputStream fileInputStream = new FileInputStream("src/main/resources/app.properties")) { +            PROPERTIES.load(fileInputStream); +        } catch (IOException ioException) { +            ioException.printStackTrace(); +        } +          try (FileInputStream fileInputStream = new FileInputStream("log.config")) {              LogManager.getLogManager().readConfiguration(fileInputStream);          } catch (IOException ioException) { @@ -29,17 +33,4 @@ public class App {          LOGGER.info("Trying to start bot");          Bot.start();      } - -    @NotNull -    private static Properties loadProperties(File file) { -        Properties properties = new Properties(); - -        try (FileInputStream fileInputStream = new FileInputStream(file)) { -            properties.load(fileInputStream); -        } catch (IOException ioException) { -            ioException.printStackTrace(); -        } - -        return properties; -    }  } |