ComposantsComponents › Fichier › GestionFile › Management
Crée une archive : un dossier en zip ou en tar.gz (tous ses fichiers, ou ceux qui correspondent à des masques), ou un seul fichier en gzip. Une archive zip peut être protégée par un mot de passe. À placer avant un envoi ou un archivage de fichiers ; tFileUnarchive fait l'inverse. Creates an archive: a folder as zip or tar.gz (all its files, or those that match masks), or a single file as gzip. A zip archive can be protected by a password. Put it before sending or archiving files; tFileUnarchive does the reverse.
EntréeInput
Aucune : il commence son sous-job. Sinon un lien Iterate, ou un lien Main : une archive par ligne reçue (voir l'exemple). None: it starts its subjob. Otherwise one Iterate link, or one Main link: one archive per received row (see the example).
SortieOutput
Le fichier archive ; son chemin et son nom vont dans des variables globales. Sa définition accepte aussi un lien Main sortant, non essayé ici. The archive file; its path and name go to global variables. Its definition also accepts an outgoing Main link, not tried here.
Déclencheurs en sortieOutput triggers
On Subjob Ok On Subjob Error On Component Ok On Component Error Run if
On Subjob : seulement quand il commence son sous-job. On Subjob: only when it starts its subjob.
On Subjob Ok ne suit que si l'archive a été écrite sans erreur. Vérifiez aussi qu'elle existe : sans fichier à archiver, aucune archive n'est créée (voir les pièges). On Subjob Ok only follows if the archive was written without error. Also check that it exists: with no file to archive, no archive is created (see the pitfalls).
Format gzip, Fichier source : ((String) globalMap.get("tFileList_1_CURRENT_FILEPATH")), Fichier archive : la même expression suivie de + ".gz".
gzip format, Source File: ((String) globalMap.get("tFileList_1_CURRENT_FILEPATH")), Archive file: the same expression followed by + ".gz".
"C:/data/out/in.zip".
Set the Directory (or the Source File) and the Archive file, as Java expressions with their quotes, extension included: "C:/data/out/in.zip".
Les libellés sont ceux de l'onglet Composant ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Labels are those of the Component tab; the technical name, in grey, is the parameter name in the job file.
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| RépertoireDirectorySOURCE | chemin par défaut des composantscomponent default path | zip ou tar.gzzip or tar.gz |
Le dossier à archiver. Dans l'archive, les chemins sont relatifs à ce dossier (archive/orders_2025-12.csv) : le dossier lui-même n'y figure pas. Un dossier absent arrête le composant.
The folder to archive. In the archive, paths are relative to this folder (archive/orders_2025-12.csv): the folder itself is not in it. A missing folder stops the component.
|
| Fichier sourceSource FileSOURCE_FILE | chemin par défaut + /source.csvdefault path + /source.csv |
gzip | Le fichier à compresser : un gzip contient un seul fichier. The file to compress: a gzip holds a single file. |
| Sous-répertoiresSubdirectoriesSUB_DIRECTROY | OuiYes | zip | Ajoute aussi les fichiers des sous-dossiers, à toute profondeur, avec leur chemin. Décochée : seulement les fichiers du dossier. En tar.gz, la case n'est pas proposée et les sous-dossiers sont toujours inclus. Also adds the files of the subfolders, at any depth, with their path. Unchecked: only the files of the folder. In tar.gz, the box is not offered and subfolders are always included. |
| Fichier archiveArchive fileTARGET | chemin par défaut + /archive.zip, /archive.tar.gz ou /source.csv.gzdefault path + /archive.zip, /archive.tar.gz or /source.csv.gz |
ToujoursAlways |
L'archive à créer, extension comprise : le nom n'est pas complété. En gzip, un nom autre que celui du fichier source suivi de .gz donne un avertissement, sans arrêter le job.
The archive to create, extension included: the name is not completed. In gzip, a name other than the source file name followed by .gz gives a warning, without stopping the job.
|
| Créer le répertoire s'il n'existe pasCreate directory if does not existMKDIR | NonNo | ToujoursAlways | Crée le dossier de l'archive, avec ses parents. Décochée, un dossier absent arrête le composant (voir les erreurs). Creates the folder of the archive, with its parents. Unchecked, a missing folder stops the component (see the errors). |
| Format de l'archiveArchive formatARCHIVE_FORMAT | zip | ToujoursAlways | zip, gzip (un fichier) ou tar.gz (un dossier, en tar compressé par gzip). zip, gzip (one file) or tar.gz (a folder, as a tar compressed with gzip). |
| Niveau de compressionCompress levelLEVEL | normal | ToujoursAlways | meilleur, normal ou rapide (aucune compression). Voir les tailles obtenues dans les exemples. best, normal or fast (no compression). See the sizes obtained in the examples. |
| Tous les fichiersAll FilesALL_FILES | OuiYes | zip ou tar.gzzip or tar.gz | Prend tous les fichiers du dossier. Décochée : seulement ceux qui correspondent à l'un des masques de Fichiers. Takes all the files of the folder. Unchecked: only those that match one of the masks of Files. |
| FichiersFilesMASK · FILEMASK | videempty | Tous les fichiers décochéAll Files unchecked |
Un Masque de fichier par ligne, expression Java entre guillemets : "*.csv". Le masque porte sur le nom du fichier et tient compte de la casse. Seul * est un joker : ? n'en est pas un (voir les pièges).
One Filemask per line, a Java expression in quotes: "*.csv". The mask applies to the file name and is case-sensitive. Only * is a wildcard: ? is not one (see the pitfalls).
|
| EncodageEncodingENCODING | "ISO-8859-15" |
zip |
L'encodage des noms des fichiers dans l'archive, pas de leur contenu. Le Studio propose ISO-8859-15, UTF-8 ou une valeur saisie. Pour des noms accentués, prenez UTF-8 : tFileUnarchive lit les noms en UTF-8 par défaut (voir les conseils).
The encoding of the file names in the archive, not of their content. The Studio offers ISO-8859-15, UTF-8 or a typed value. For accented names, take UTF-8: tFileUnarchive reads names as UTF-8 by default (see the tips).
|
| Écraser l'archive existanteOverwrite Existing ArchiveOVERWRITE | OuiYes | ToujoursAlways |
Une archive existante est supprimée avant d'écrire la nouvelle, même si aucun fichier n'est trouvé ensuite. Décochée : le composant s'arrête avec File already exist!.
An existing archive is deleted before writing the new one, even if no file is found afterwards. Unchecked: the component stops with File already exist!.
|
| Chiffrer les fichiersEncrypt filesENCRYPT_FILES | NonNo | zip | Protège l'archive par le mot de passe saisi plus bas. Protects the archive with the password entered below. |
| Méthode de chiffrementEncrypt methodENCRYPT_METHOD | Zip4j STANDARD | zip, chiffrement cochézip, encryption checked | Zip4j AES et Zip4j STANDARD : chiffrement du format zip lui-même, entrée par entrée ; STANDARD est l'ancien chiffrement zip, le plus faible. Chiffrement Java : le fichier entier est chiffré ; ce n'est plus un zip, seul tFileUnarchive en Déchiffrement Java le relit (voir les exemples). Zip4j AES and Zip4j STANDARD: encryption of the zip format itself, entry by entry; STANDARD is the old zip encryption, the weakest. Java Encrypt: the whole file is encrypted; it is no longer a zip, only tFileUnarchive with Java Decrypt reads it back (see the examples). |
| Complexité de la clé AESAES Key StrengthAES_KEY_STRENGTH | AES 256 | Zip4j AESZip4j AES | AES 128 ou AES 256 : la longueur de la clé. AES 128 or AES 256: the key length. |
| Saisir le mot de passeEnter PasswordPASSWORD | videempty | zip, chiffrement cochézip, encryption checked |
Le mot de passe, en expression Java ("secret", context.zipPassword), saisi dans la fenêtre du bouton … ; il est enregistré chiffré dans le job.
The password, as a Java expression ("secret", context.zipPassword), entered in the window of the … button; it is saved encrypted in the job.
|
| Mode ZIP64ZIP64 modeZIP64_MODE | ASNEEDED | zip, sauf chiffrement Zip4jzip, except Zip4j encryption | L'extension ZIP64 du format zip, pour les très grosses archives : ASNEEDED (si besoin), ALWAYS (toujours) ou NEVER (jamais). Transmis à la bibliothèque Apache Commons Compress ; d'après le modèle, non essayé ici. The ZIP64 extension of the zip format, for very large archives: ASNEEDED (when needed), ALWAYS or NEVER. Passed to the Apache Commons Compress library; from the template, not tried here. |
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| Utiliser syncFlushUse sync flushUSE_SYNC_FLUSH | NonNo | gzip ou tar.gzgzip or tar.gz |
Transmis au flux gzip de Java (son option syncFlush). D'après le modèle, non essayé ici.
Passed to the Java gzip stream (its syncFlush option). From the template, not tried here.
|
À lire après le composant (par exemple dans un tJava relié par On Subjob Ok). Elles sont remplies avant l'écriture de l'archive : elles ont une valeur même quand aucune archive n'a été créée. To read after the component (for example in a tJava connected with On Subjob Ok). They are filled before the archive is written: they have a value even when no archive was created.
C:/data/out/in.zip.The archive path, as given in Archive file: C:/data/out/in.zip.in.zip.The archive name, without the path: in.zip.((String) globalMap.get("tFileArchive_1_ARCHIVE_FILEPATH"))
((String) globalMap.get("tFileArchive_1_ARCHIVE_FILENAME"))
Les chemins sont écrits à partir de la variable de contexte folder : context.folder + "/in". Dans les sorties, ce dossier est raccourci en C:/data. Un tJava relié par On Subjob Ok affiche le contenu de l'archive ; les sorties sont celles de la console, copiées depuis une exécution du job.
Paths are written from the folder context variable: context.folder + "/in". In the outputs, this folder is shortened to C:/data. A tJava connected with On Subjob Ok prints the archive content; the outputs are the console ones, copied from a run of the job.
in/
archive/
orders_2025-12.csv 16 bytes
customers.csv 22 bytes
notes.txt 9 bytes
orders_2026-01.csv 21 bytes
orders_2026-02.csv 15 bytes
Répertoire : context.folder + "/in" ; Fichier archive : context.folder + "/out/in.zip".
Directory: context.folder + "/in"; Archive file: context.folder + "/out/in.zip".
String path = (String) globalMap.get("tFileArchive_1_ARCHIVE_FILEPATH");
System.out.println(path + " (" + globalMap.get("tFileArchive_1_ARCHIVE_FILENAME") + ")");
java.util.zip.ZipFile zip = new java.util.zip.ZipFile(path);
zip.stream().forEach(ze -> System.out.println(" " + ze.getName() + " " + ze.getSize() + " bytes"));
zip.close();
C:/data/out/in.zip (in.zip) archive/orders_2025-12.csv 16 bytes customers.csv 22 bytes notes.txt 9 bytes orders_2026-01.csv 21 bytes orders_2026-02.csv 15 bytes
Sous-répertoires et Tous les fichiers décochés, masque "*.csv", archive csv.zip. Même tJava.
Subdirectories and All Files unchecked, "*.csv" mask, csv.zip archive. Same tJava.
C:/data/out/csv.zip (csv.zip) customers.csv 22 bytes orders_2026-01.csv 21 bytes orders_2026-02.csv 15 bytes
archive/orders_2025-12.csv n'est pas pris : il est dans un sous-dossier.
archive/orders_2025-12.csv is not taken: it is in a subfolder.
Format tar.gz, Tous les fichiers décoché, masque "*.csv", archive csv.tar.gz. Le tJava lit l'archive avec Apache Commons Compress, déjà dans le job.
tar.gz format, All Files unchecked, "*.csv" mask, csv.tar.gz archive. The tJava reads the archive with Apache Commons Compress, already in the job.
org.apache.commons.compress.archivers.tar.TarArchiveInputStream tar =
new org.apache.commons.compress.archivers.tar.TarArchiveInputStream(
new java.util.zip.GZIPInputStream(new java.io.FileInputStream(path)));
for (org.apache.commons.compress.archivers.tar.TarArchiveEntry te;
(te = tar.getNextTarEntry()) != null;) {
System.out.println(" " + te.getName() + " " + te.getSize() + " bytes");
}
tar.close();
C:/data/out/csv.tar.gz archive/orders_2025-12.csv 16 bytes customers.csv 22 bytes orders_2026-01.csv 21 bytes orders_2026-02.csv 15 bytes
En tar.gz, les sous-dossiers sont toujours inclus. In tar.gz, subfolders are always included.
Format gzip, Fichier source context.folder + "/in/customers.csv", archive customers.csv.gz. Le tJava affiche la taille, puis relit l'archive.
gzip format, Source File context.folder + "/in/customers.csv", customers.csv.gz archive. The tJava prints the size, then reads the archive back.
java.io.BufferedReader r = new java.io.BufferedReader(new java.io.InputStreamReader(
new java.util.zip.GZIPInputStream(new java.io.FileInputStream(path))));
for (String line; (line = r.readLine()) != null;) {
System.out.println(" " + line);
}
r.close();
customers.csv.gz 42 bytes id;name 1;Ada 2;Grace
Avec l'archive nommée customers.gz, le résultat est le même, avec un avertissement en tête (sortie d'erreur) :
With the archive named customers.gz, the result is the same, with a warning first (error output):
WARNING: It is better that the gzip file change from "customers.gz" to "customers.csv.gz".
Trois tFileArchive à la suite (On Subjob Ok) archivent le même fichier texte de 1 000 lignes, en meilleur, normal et rapide. Le tJava affiche les tailles. Three tFileArchive in a row (On Subjob Ok) archive the same 1,000-line text file, as best, normal and fast. The tJava prints the sizes.
report.txt 23509 bytes best.zip 5915 bytes normal.zip 6217 bytes fast.zip 23648 bytes
Rapide ne compresse pas : l'archive est un peu plus grosse que le fichier. Fast does not compress: the archive is slightly larger than the file.
Masque "*.csv" sans sous-répertoires, Chiffrer les fichiers coché, Zip4j AES, AES 256, mot de passe "secret". Le tJava lit l'archive avec Zip4j, déjà dans le job.
"*.csv" mask without subdirectories, Encrypt files checked, Zip4j AES, AES 256, password "secret". The tJava reads the archive with Zip4j, already in the job.
net.lingala.zip4j.ZipFile zip = new net.lingala.zip4j.ZipFile(path);
System.out.println("Encrypted: " + zip.isEncrypted());
for (net.lingala.zip4j.model.FileHeader h : zip.getFileHeaders()) {
System.out.println(" " + h.getFileName() + " " + h.getEncryptionMethod()
+ (h.getAesExtraDataRecord() == null ? ""
: " " + h.getAesExtraDataRecord().getAesKeyStrength()));
}
Encrypted: true customers.csv AES KEY_STRENGTH_256 orders_2026-01.csv AES KEY_STRENGTH_256 orders_2026-02.csv AES KEY_STRENGTH_256
En Zip4j STANDARD : With Zip4j STANDARD:
Encrypted: true customers.csv ZIP_STANDARD orders_2026-01.csv ZIP_STANDARD orders_2026-02.csv ZIP_STANDARD
Le dossier entier, Chiffrement Java, mot de passe "secret". Le tJava essaie d'ouvrir le résultat comme un zip :
The whole folder, Java Encrypt, password "secret". The tJava tries to open the result as a zip:
try {
new java.util.zip.ZipFile(path).close();
System.out.println("Readable zip");
} catch (java.io.IOException ex) {
System.out.println(ex);
}
java.util.zip.ZipException: zip END header not found
Le fichier n'est plus un zip. tFileUnarchive le relit en Déchiffrement Java, pas en Déchiffrement Zip4j (voir tFileUnarchive). The file is no longer a zip. tFileUnarchive reads it back with Java Decrypt, not with Zip4j Decrypt (see tFileUnarchive).
Le tFixedFlowInput envoie deux lignes, north et south, dans une colonne name. Fichier archive : context.folder + "/out/flow_" + row1.name + ".zip", masque "*.txt". Un tJava relié au tFixedFlowInput par On Subjob Ok liste les archives :
The tFixedFlowInput sends two rows, north and south, in a name column. Archive file: context.folder + "/out/flow_" + row1.name + ".zip", "*.txt" mask. A tJava connected to the tFixedFlowInput with On Subjob Ok lists the archives:
for (String n : new java.io.File(context.folder + "/out").list()) {
if (n.startsWith("flow_")) System.out.println(n);
}
System.out.println("Last: " + globalMap.get("tFileArchive_1_ARCHIVE_FILENAME"));
flow_north.zip flow_south.zip Last: flow_south.zip
Le nom du job est remplacé par MyJob, le dossier de travail par C:/data ; les traces d'exception sont abrégées. Dans les trois cas, le job s'arrête avec le code 1.
The job name is replaced with MyJob, the working folder with C:/data; exception traces are shortened. In the three cases, the job stops with exit code 1.
Écraser l'archive existante décoché, in.zip déjà présent :
Overwrite Existing Archive unchecked, in.zip already there:
Exception in component tFileArchive_1 (MyJob) java.lang.Exception: File already exist! at com.talend.compress.zip.Zip.checkTargetFilePath(Zip.java:140) at com.talend.compress.zip.Zip.doZip(Zip.java:157) …
Répertoire : context.folder + "/missing", qui n'existe pas :
Directory: context.folder + "/missing", which does not exist:
Exception in component tFileArchive_1 (MyJob) java.io.FileNotFoundException: C:/data/missing (The system cannot find the path specified) at demo.myjob_0_1.MyJob.tFileArchive_1Process(MyJob.java:418) …
Fichier archive : context.folder + "/out/new/in.zip", dossier new absent, Créer le répertoire s'il n'existe pas décoché. La fin du message vient de Windows, dans sa langue :
Archive file: context.folder + "/out/new/in.zip", new folder missing, Create directory if does not exist unchecked. The end of the message comes from Windows, in its language:
Exception in component tFileArchive_1 (MyJob) java.io.FileNotFoundException: C:\data\out\new\in.zip (Le chemin d’accès spécifié est introuvable) at java.base/java.io.FileOutputStream.open0(Native Method) … at com.talend.compress.zip.Zip.doZip1(Zip.java:262) …
Case cochée, avec context.folder + "/out/new2/sub/in.zip" : les deux dossiers sont créés et l'archive écrite.
Box checked, with context.folder + "/out/new2/sub/in.zip": both folders are created and the archive written.
Masque "*.CSV" (en majuscules) ; une archive old.zip existe déjà à l'endroit du Fichier archive. Le tJava teste son existence :
"*.CSV" mask (upper case); an old.zip archive already exists where the Archive file goes. The tJava tests its existence:
String path = (String) globalMap.get("tFileArchive_1_ARCHIVE_FILEPATH");
System.out.println(path + " exists: " + new java.io.File(path).exists());
C:/data/out/old.zip exists: false
Le masque tient compte de la casse : aucun fichier .csv n'est retenu. L'ancienne archive a été supprimée, aucune n'a été écrite, et le job se termine normalement. Testez l'existence de l'archive avant la suite (un Run if avec new java.io.File(…).exists()).
The mask is case-sensitive: no .csv file is kept. The old archive was deleted, none was written, and the job ends normally. Test that the archive exists before going on (a Run if with new java.io.File(…).exists()).
? n'est pas un joker? is not a wildcard
Masque "orders_2026-0?.csv", pour trouver orders_2026-01.csv et orders_2026-02.csv. Même tJava :
"orders_2026-0?.csv" mask, to find orders_2026-01.csv and orders_2026-02.csv. Same tJava:
C:/data/out/q.zip exists: false
Le masque devient une expression régulière où seuls * et . sont traduits : ? y garde son sens (« le caractère précédent est facultatif »), et rien n'est trouvé. Écrivez "orders_2026-*.csv".
The mask becomes a regular expression where only * and . are translated: ? keeps its meaning there (“the previous character is optional”), and nothing is found. Write "orders_2026-*.csv".
Avec l'Encodage par défaut (ISO-8859-15), un fichier résumé.txt archivé n'est pas extrait par tFileUnarchive avec ses réglages par défaut : il faut lui indiquer le même encodage. Avec UTF-8 ici, l'extraction par défaut redonne le bon nom (voir tFileUnarchive).
With the default Encoding (ISO-8859-15), an archived résumé.txt file is not extracted by tFileUnarchive with its default settings: it must be given the same encoding. With UTF-8 here, the default extraction gives the right name back (see tFileUnarchive).
Une archive en Chiffrement Java ne s'ouvre qu'avec tFileUnarchive. Pour une archive à envoyer à quelqu'un, prenez Zip4j AES. An archive with Java Encrypt only opens with tFileUnarchive. For an archive to send to someone, take Zip4j AES.
Les bibliothèques du composant (Zip4j, Apache Commons Compress) sont dans le job : un tJava peut les utiliser sans tLibraryLoad, comme dans les exemples, pour vérifier le contenu de l'archive. The component libraries (Zip4j, Apache Commons Compress) are in the job: a tJava can use them without tLibraryLoad, as in the examples, to check the archive content.
Le mot de passe est une expression : context.zipPassword, avec une variable de contexte de type Password, permet de le changer selon l'environnement sans modifier le job.
The password is an expression: context.zipPassword, with a context variable of the Password type, lets you change it per environment without editing the job.
tFileUnarchive · extraire une archiveextract an archivetFileList · une itération par fichier d'un dossierone iteration per file of a foldertFileCopy · tFileDelete · copier ou supprimer des fichierscopy or delete filestFileExist · tFileProperties · tester l'archive, lire sa tailletest the archive, read its sizetGPGDecrypt · déchiffrer un fichier OpenPGPdecrypt an OpenPGP filetChangeFileEncoding · changer l'encodage d'un fichier textechange the encoding of a text file