Kenmegne
6 days ago 8cbaa370347e6fc997381cf35d6c295685b90f98
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
36
37
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.megatim.dynamicjsonparser.utils;
 
import com.megatim.dynamicjsonparser.pojo.CustomError;
import java.io.BufferedWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.List;
 
/**
 *
 * @author ASUS
 */
public class Utility {
     /**
     * Méthode qui écrit une liste de String dans un fichier
     *
     * @param errors
     * @param errorPath : Chemin du fichier
     */
    public static void writeToFile(List<CustomError> errors, Path errorPath) {
 
        try ( BufferedWriter bufferWriter = Files.newBufferedWriter(errorPath, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.CREATE, StandardOpenOption.SYNC)) {
 
            for (CustomError c : errors) {
                bufferWriter.write(c.getMessage() + System.lineSeparator());
            }
        } catch (Exception ex) {
 
        }
    }
}