ImportData + test ImportData
Le code est fonctionnel javadoc
This commit is contained in:
parent
2eb99132c7
commit
15f5c1068a
1 changed files with 11 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ public class ImportData {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Le constructeur de ImportData
|
* Le constructeur de ImportData
|
||||||
|
* Initialise l'URL par défaut ainsi que le dossier de destination de téléchargement
|
||||||
*/
|
*/
|
||||||
ImportData(){
|
ImportData(){
|
||||||
this.url = "https://www.fdj.fr/jeux-de-tirage/loto/statistiques";
|
this.url = "https://www.fdj.fr/jeux-de-tirage/loto/statistiques";
|
||||||
|
|
@ -29,6 +30,10 @@ public class ImportData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Méthode permettant de tester si l'URL est valide
|
||||||
|
* @return true si l'URL est valide si non false
|
||||||
|
*/
|
||||||
private boolean UrlExist() {
|
private boolean UrlExist() {
|
||||||
try {
|
try {
|
||||||
URL site = new URL(url);
|
URL site = new URL(url);
|
||||||
|
|
@ -43,6 +48,12 @@ public class ImportData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Méthode permettant de télécharger un fichier à partir d'un URL
|
||||||
|
* Séquence du code :
|
||||||
|
* - récupération du lien du fichier à télécharger à partir du code source de la page
|
||||||
|
* - enregistrement du fichier télécharger dans le répertoire définit dans le constructeur
|
||||||
|
*/
|
||||||
public void DownloadCsvZip() {
|
public void DownloadCsvZip() {
|
||||||
if (UrlExist()) {
|
if (UrlExist()) {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
|
|
|
||||||
Reference in a new issue