Package fr.formiko.usuel
Class fichier
java.lang.Object
fr.formiko.usuel.fichier
tools about Files.
- Author:
- Hydrolien Baeldung
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidcopierUnFichier(String fileSourceName)static voidcopierUnFichier(String fileSourceName, String fileTargetName)static booleandeleteDirectory(File directoryToBeDeleted)Delete a directory and all his content.static booleanstatic booleanstatic booleanDownload a file from the web.static voidprivate static longgetFileSize(URL url)return the size of the downloaded file.static GStringmake a liste of all .java file in the directory f.static GStringlisterLesFichiersDuRep(String rep)static Filea safe way to create a File from a zip file to avoid Zip Slip.static booleana safe way to open an URI.static booleanopenWebLink(String url)a safe way to launch a web page.static voida class to unzip file.static voida class to zip file.private static voidzipFile(File fileToZip, String fileName, ZipOutputStream zipOut, String outputFile)a class to do main part of ziping a file.
-
Constructor Details
-
fichier
public fichier()
-
-
Method Details
-
listerLesFichiersDuRep
make a liste of all .java file in the directory f.- Parameters:
f- The directory were to search java file.
-
listerLesFichiersDuRep
-
deleteDirectory
Delete a directory and all his content.
If it's a folder it will call deleteDirectory on all sub file/folder and then destroy itself. If it's a file it will destroy itself. -
deleteDirectory
-
affichageDesLecteurALaRacine
-
fichierCiblePeuAvoirCeNom
-
copierUnFichier
-
copierUnFichier
-
download
Download a file from the web.- Parameters:
urlPath- the url as a StringfileName- the name of the file were to save data from the webwithInfo- if true launch a thread to have info during download
-
download
-
getFileSize
return the size of the downloaded file. -
zip
a class to zip file.
cf https://www.baeldung.com/java-compress-and-uncompress -
zipFile
private static void zipFile(File fileToZip, String fileName, ZipOutputStream zipOut, String outputFile)a class to do main part of ziping a file.
cf https://www.baeldung.com/java-compress-and-uncompress -
unzip
a class to unzip file.
cf https://www.baeldung.com/java-compress-and-uncompress- Parameters:
fileName- the name of the .zip file.folderName- the name of the folder were to save data from the .zip.
-
newFile
a safe way to create a File from a zip file to avoid Zip Slip.- Parameters:
destinationDir- File that we whant to create in the zipEntry folder.zipEntry- the ZipEntry.- Throws:
IOException
-
openWebLink
a safe way to launch a web page.- Parameters:
url- the URL to open
-
openURI
a safe way to open an URI.- Parameters:
uri- the URI to open
-