Нужно найти файлы messages.properties в папках, затем вытащить ключи и загрузить их в excel

Поиск файла: `public class Keys { public static final String PATH_TO_PROPERTIES = "C:/Users/a.kazybek/IdeaProjects/cubabpm/modules/web/src/com/company/cubabpm/web/messages.properties";

public static void main(String[] args) throws IOException {

    HashMap<String, String> map = new HashMap<>();
        Properties property = new Properties();
        FileInputStream fileInputStream = new FileInputStream(PATH_TO_PROPERTIES);
        property.load(fileInputStream);
        for (Map.Entry<Object, Object> entry : property.entrySet()) {
            map.put((String) entry.getKey(), (String) entry.getValue());
            System.out.println(map);
        }
    }
}` 

Перевод ключей messages.properties в HashMap из одного файла, хотя нужно из всех файлов(ошибка тут, но с одним определенным файлом работает):

public class Keys {
public static final String PATH_TO_PROPERTIES = "C:/Users/a.kazybek/IdeaProjects/cubabpm/modules/web/src/com/company/cubabpm/web/messages.properties";

public static void main(String[] args) throws IOException {

    HashMap<String, String> map = new HashMap<>();
        Properties property = new Properties();
        FileInputStream fileInputStream = new FileInputStream(PATH_TO_PROPERTIES);
        property.load(fileInputStream);
        for (Map.Entry<Object, Object> entry : property.entrySet()) {
            map.put((String) entry.getKey(), (String) entry.getValue());
            System.out.println(map);
        }
    }
}

Выгрузка в Excek {ключ} и {значение} excel(ничего не получилось):

ublic class Excel {

    public static final String PATH_TO_PROPERTIES = "C: /Users/a.kazybek/IdeaProjects/cubabpm/modules/core/src/com/company/cubabpm/core/messages.properties";

    public HashMap<String, String> mapOfKeys() throws IOException {
        Properties property = new Properties();
        FileInputStream fileInputStream = new FileInputStream(PATH_TO_PROPERTIES);
        property.load(fileInputStream);
        for (Map.Entry<Object, Object> entry: property.entrySet()) {
            mapOfKeys().put((String) entry.getKey(), (String) entry.getValue());
            System.out.println(mapOfKeys());
        }
        return null;
    }

public static HSSFCellStyle createStyleForTitle(HSSFWorkbook workBook) {
    HSSFFont font = workBook.createFont();
    font.setBold(true);
    HSSFCellStyle style = workBook.createCellStyle();
    style.setFont(font);
    return style;
}

public static void main(String[] args) throws IOException {
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet("field sheet");

    int rownum = 0;
    Cell cell;
    Row row;

    HSSFCellStyle style = createStyleForTitle(workbook);

    row = sheet.createRow(rownum);

    cell = row.createCell(0, CellType.STRING);
    cell.setCellValue("directory");
    cell.setCellStyle(style);

    cell = row.createCell(1, CellType.STRING);
    cell.setCellValue("key");
    cell.setCellStyle(style);

    cell = row.createCell(2, CellType.STRING);
    cell.setCellValue("value");
    cell.setCellStyle(style);

    for (Map.Entry entry : mapOfExcel.entrySet()) {
        rownum++;
        row = sheet.createRow(rownum);

        cell = row.createCell(0, CellType.STRING);
        cell.setCellValue("");

        cell = row.createCell(1, CellType.STRING);
        cell.setCellValue((String) entry.getKey());

        cell = row.createCell(2, CellType.STRING);
        cell.setCellValue((String) entry.getValue());
    }

    File file = new File("C:/Users/a.kazybek/IdeaProjects/fileds.xls");
    file.getParentFile().mkdirs();
    FileOutputStream outFile = new FileOutputStream(file);
    workbook.write(outFile);
    System.out.println("Created file: " + file.getAbsolutePath());
}

}


Ответы (0 шт):