GestionDesInscriptions/src/outils/lectureFileToString.java
2023-07-09 21:11:39 +02:00

29 lines
741 B
Java

package outils;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class lectureFileToString {
public static String lecture(String filePath) {
String xmlString = "";
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"))) {
StringBuilder content = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
content.append(line).append("\n");
}
xmlString = content.toString();
} catch (IOException e) {
e.printStackTrace();
}
return xmlString;
}
}