/**
 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.jboot.app.config;

import java.io.*;
import java.util.Properties;


class JbootProp {
    protected Properties properties = null;
    private static final String DEFAULT_ENCODING = "UTF-8";

    public JbootProp(String fileName) {
        this(fileName, DEFAULT_ENCODING);
    }

    public JbootProp(String fileName, String encoding) {
        properties = new Properties();
        InputStream inputStream = null;
        try {
            inputStream = JbootConfigKit.getClassLoader().getResourceAsStream(fileName);
            if (inputStream != null) {
                properties.load(new InputStreamReader(inputStream, encoding));
            } else {
                System.err.println("Warning: Can not load properties file in classpath, file name: " + fileName);
            }
        } catch (Exception e) {
            System.err.println("Warning: Can not load properties file in classpath, file name: " + fileName);
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                }
            }
        }
    }


    public JbootProp(File file) {
        properties = new Properties();
        try (InputStream inputStream = new FileInputStream(file)) {
            properties.load(new InputStreamReader(inputStream, DEFAULT_ENCODING));
        } catch (Exception e) {
            System.err.println("Warning: Can not load properties file: " + file);
        }
    }

    public Properties getProperties() {
        return properties;
    }
}

@@ -682,16 +682,37 @@
 a.io.*;%0A
+import java.net.URL;%0A
 import j
@@ -732,16 +732,16 @@
 erties;%0A
-
 %0A%0Aclass 
@@ -1177,32 +1177,857 @@
 ream(fileName);%0A
+%0A            // %E5%BD%93%E7%B3%BB%E7%BB%9F%E6%9C%AA%E7%BC%96%E8%AF%91%E7%9A%84%E6%97%B6%E5%80%99%EF%BC%8C%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E4%B8%8B%E7%9A%84 resources %E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84 jboot.properties %E6%96%87%E4%BB%B6%E4%B8%8D%E4%BC%9A%E8%87%AA%E5%8A%A8%E8%A2%AB copy %E5%88%B0 target/classes %E7%9B%AE%E5%BD%95%E4%B8%8B%0A            // %E6%AD%A4%E6%97%B6%EF%BC%8C%E9%9C%80%E8%A6%81%E4%B8%BB%E5%8A%A8%E5%8E%BB%E6%8E%A2%E6%B5%8B resources %E7%9B%AE%E5%BD%95%E7%9A%84%E6%96%87%E4%BB%B6%0A            if (inputStream == null) %7B%0A                URL resourceURL = JbootProp.class.getResource(%22/%22);%0A                if (resourceURL != null) %7B%0A                    String classPath = resourceURL.toURI().getPath();%0A                    if (removeSlashEnd(classPath).endsWith(%22classes%22)) %7B%0A                        File resourcesDir = new File(classPath, %22../../src/main/resources%22);%0A                        File propFile = new File(resourcesDir, fileName);%0A                        if (propFile.exists() && propFile.isFile()) %7B%0A                            inputStream = new FileInputStream(propFile);%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D%0A%0A
             if (
@@ -2633,16 +2633,250 @@
     %7D%0A%0A%0A
+    private static String removeSlashEnd(String path) %7B%0A        if (path != null && path.endsWith(File.separator)) %7B%0A            return path.substring(0, path.length() - 1);%0A        %7D else %7B%0A            return path;%0A        %7D%0A    %7D%0A%0A%0A
     publ
@@ -3215,23 +3215,24 @@
       %7D%0A
-
     %7D%0A%0A
+%0A
     publ

optimize JbootProp.java