|
@@ -2,7 +2,6 @@ package db;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URISyntaxException;
|
|
|
import java.net.URL;
|
|
@@ -31,7 +30,7 @@ public abstract class DatabaseManager {
|
|
|
URL ressource = DatabaseManager.class.getResource(sqlFile);
|
|
|
return readSQLFile(new File(ressource.toURI()));
|
|
|
} catch (URISyntaxException e) {
|
|
|
- LOGGER.severe("Unable to find SQL File: " + e.getMessage());
|
|
|
+ LOGGER.severe("Unable to find SQL file: " + e.getMessage());
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
}
|
|
@@ -44,17 +43,8 @@ public abstract class DatabaseManager {
|
|
|
// Lecture du fichier
|
|
|
try {
|
|
|
FileInputStream fis = new FileInputStream(sqlFile);
|
|
|
- return readSQLFile(fis);
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- LOGGER.severe("Unable to find SQL File: " + e.getMessage());
|
|
|
- return new ArrayList<>();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public List<String> readSQLFile(FileInputStream fis) {
|
|
|
- try {
|
|
|
- byte[] data = fis.readAllBytes();
|
|
|
+ byte[] data = new byte[(int) sqlFile.length()];
|
|
|
+ fis.read(data);
|
|
|
fis.close();
|
|
|
String sql = new String(data, "UTF-8");
|
|
|
return Arrays.asList(sql.split(";\n")).stream().filter(elt -> !elt.trim().isEmpty()).collect(Collectors.toList());
|