public static void writePropertiesFile(
        Properties props,
        String path,
        boolean fsync
    ) throws IOException {
        File tempFile = new File(path + ".tmp");
        try (
            FileOutputStream fos = new FileOutputStream(tempFile, false);
            OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
            PrintWriter pw = new PrintWriter(osw)
        ) {
            props.store(pw, "");
            fos.flush();
            if (fsync) {
                fos.getFD().sync();
            }
        }
        File targetFile = new File(path);
        try {
            Utils.atomicMoveWithFallback(tempFile.toPath(), targetFile.toPath(), fsync);
        } catch (Throwable e) {
            Utils.delete(tempFile);
            throw e;
        }
    }
Writes a Java Properties object to a file.

@param props         The Properties object.
@param path          The file to write to.
@throws IOException
metadata/src/main/java/org/apache/kafka/metadata/properties/PropertiesUtils.java