许鹏程
2024-09-30 f1579ea6e661af4ed4fb4d4a1dbbe4f5bc75c284
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.product.file.util;
 
import com.product.core.exception.BaseException;
import com.product.file.config.FileCode;
 
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
 
/**
 * Copyright © 6c
 *
 * @Date: 2021-03-05 10:59
 * @Author: 6c
 * @Description:
 */
public class CommonUtil {
    private CommonUtil() {}
 
    /**
     * 获取指定配置文件中的信息
     * @return
     */
    public static Properties getProperties() {
        String path = System.getProperty("user.dir");
        path = path + "/../../file/file.properties";
        Properties properties = new Properties();
        try (FileReader reader = new FileReader(path);) {
            properties.load(reader);
            return properties;
        } catch (IOException e) {
            throw new BaseException(FileCode.LOAD_FTP_PROPERTIES_FAIL.getValue(), FileCode.LOAD_FTP_PROPERTIES_FAIL.getText(), e);
        }
    }
}