ComposantsComponents › Fichier › SortieFile › Output
Écrit des paires clé/valeur dans un fichier de propriétés Java (.properties) ou dans une section d'un fichier .ini : une paire par ligne du flux, prise dans les deux colonnes key et value de son schéma fixe. Il sert à enregistrer des réglages produits par un job, pour un autre job ou un autre programme.
Writes key/value pairs to a Java properties file (.properties) or to a section of an .ini file: one pair per flow row, taken from the two key and value columns of its fixed schema. It is used to save settings produced by a job, for another job or another program.
EntréeInput
Main un flux, obligatoire, avec les colonnes key et valueone flow, required, with the key and value columns
SortieOutput
Main un flux, facultatif : les lignes repartent telles quellesone flow, optional: the rows go on unchanged
Déclencheurs en sortieOutput triggers
On Component Ok On Component Error Run if
key et value (clic droit › Ligne › Main). Le schéma du composant est fixe, et d'après le modèle le code lit ces deux noms dans la ligne entrante : renommez les colonnes avant, dans un tMap, au besoin.
Connect a flow that has two key and value columns to it (right-click › Row › Main). The component schema is fixed, and from the template the code reads these two names in the incoming row: rename the columns before, in a tMap, if needed.
.ini, le Nom de section et, dans les paramètres avancés, l'Encodage.
Choose the File Format, then the File Name; in .ini, the Section Name and, in the advanced settings, the Encoding.
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 |
|---|---|---|---|
| SchémaSchemaSCHEMA | key, value |
ToujoursAlways | Deux colonnes String, en lecture seule : la clé et sa valeur. Two String columns, read-only: the key and its value. |
| Format de fichierFile FormatFILE_FORMAT | .properties |
ToujoursAlways |
.properties : fichier de propriétés Java, écrit par java.util.Properties, une ligne clé=valeur par paire. .ini : fichier INI, écrit par la bibliothèque ini4j 0.5.1, des lignes clé = valeur sous un titre [section].
.properties: Java properties file, written by java.util.Properties, one key=value line per pair. .ini: INI file, written by the ini4j 0.5.1 library, key = value lines under a [section] title.
|
| Nom de sectionSection NameSECTION_NAME | "section" |
Format .ini.ini format | La section qui reçoit les paires, en expression Java. Un composant n'écrit qu'une section : pour en écrire plusieurs, enchaînez plusieurs composants avec Écrire à la suite de. The section that receives the pairs, as a Java expression. A component writes only one section: to write several, chain several components with Append. |
| Écrire à la suite deAppendAPPEND | NonNo | ToujoursAlways |
Garde les paires du fichier existant : une clé déjà présente prend la nouvelle valeur, à sa place ; une nouvelle clé s'ajoute à la fin (de sa section en .ini). Décochée, le fichier est supprimé puis réécrit. Voir les exemples.
Keeps the pairs of the existing file: a key already there takes the new value, at its place; a new key is added at the end (of its section in .ini). Unchecked, the file is deleted then written again. See the examples.
|
| Nom de fichierFile NameFILENAME | chemin par défaut + /out.propertiesdefault path + /out.properties |
ToujoursAlways |
Le fichier écrit, en expression Java : context.folder + "/app.properties". Son dossier est créé s'il n'existe pas, sans réglage pour l'éviter. Un nom sans dossier arrête le job (voir les erreurs).
The written file, as a Java expression: context.folder + "/app.properties". Its folder is created if it does not exist, with no setting to avoid it. A name without a folder stops the job (see the errors).
|
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| EncodageEncodingENCODING | "ISO-8859-15" |
ToujoursAlways |
.ini seulement : l'encodage du fichier écrit (exemple). En .properties, il est sans effet : Java écrit le fichier en ASCII, les autres caractères en \uXXXX (é devient é).
.ini only: the encoding of the written file (example). In .properties, it has no effect: Java writes the file in ASCII, the other characters as \uXXXX (é becomes é).
|
NB_LINE (Integer, disponible après l'exécution du composant) : nombre de lignes reçues, doublons compris. Dans le premier exemple, quatre lignes donnent NB_LINE: 4 pour trois clés écrites.
NB_LINE (Integer, available after the component has run): number of rows received, duplicates included. In the first example, four rows give NB_LINE: 4 for three keys written.
System.out.println("NB_LINE: " + globalMap.get("tFileOutputProperties_1_NB_LINE"));
Un tFixedFlowInput envoie les paires au composant. Les chemins sont écrits à partir de la variable de contexte folder. Un tJava relié par On Subjob Ok affiche ensuite le fichier ligne par ligne ; les sous-jobs s'enchaînent par On Subjob Ok. Les sorties sont celles de la console, copiées depuis une exécution du job.
A tFixedFlowInput sends the pairs to the component. Paths are written from the folder context variable. A tJava connected with On Subjob Ok then prints the file line by line; the subjobs are chained with On Subjob Ok. The outputs are the console ones, copied from a run of the job.
for (String l : java.nio.file.Files.readAllLines(
java.nio.file.Paths.get(context.folder + "/props/app.properties"),
java.nio.charset.Charset.forName("ISO-8859-1"))) {
System.out.println(l);
}
Quatre lignes, dont deux pour la clé db.host. Nom de fichier context.folder + "/props/app.properties", réglages par défaut.
Four rows, two of them for the db.host key. File Name context.folder + "/props/app.properties", default settings.
| key | value |
|---|---|
| db.host | localhost |
| db.url | jdbc:postgresql://db01:5432/app |
| app.title | Café crème |
| db.host | db01 |
# #Wed Nov 11 20:17:00 CET 2026 db.host=db01 db.url=jdbc\:postgresql\://db01\:5432/app app.title=Café crème NB_LINE: 4
#), puis la date de l'écriture.
Two comment lines first: an empty comment (#), then the date of the writing.
db.host a remplacé la valeur de la première, à sa place.
The keys follow their arrival order. The second db.host row replaced the value of the first one, at its place.
: sont précédés de \, les accents écrits en \uXXXX : c'est l'écriture de Java, que java.util.Properties et tFileInputProperties relisent en clair.
The : are preceded by \, accents are written as \uXXXX: this is how Java writes it, and java.util.Properties and tFileInputProperties read it back as plain text.
Puis, sur le même fichier, Écrire à la suite de coché, deux lignes : db.host = db02, app.lang = fr.
Then, on the same file, Append checked, two rows: db.host = db02, app.lang = fr.
# #Wed Nov 11 20:17:00 CET 2026 db.host=db02 db.url=jdbc\:postgresql\://db01\:5432/app app.title=Café crème app.lang=fr
db.host change à sa place, app.lang s'ajoute à la fin. Le fichier est relu puis réécrit en entier, avec un nouvel en-tête : d'après le modèle, ses anciens commentaires ne sont pas gardés.
db.host changes at its place, app.lang is added at the end. The file is read then fully rewritten, with a new header: from the template, its old comments are not kept.
Enfin, Écrire à la suite de décoché, une ligne : app.lang = en.
Finally, Append unchecked, one row: app.lang = en.
# #Wed Nov 11 20:17:00 CET 2026 app.lang=en
Le fichier est remplacé : il ne reste que la nouvelle paire. The file is replaced: only the new pair is left.
Format de fichier .ini, Nom de section "database", Encodage "UTF-8", fichier app.ini. Quatre lignes : host = db01, port = 5432, title = Café crème, empty = "".
File Format .ini, Section Name "database", Encoding "UTF-8", file app.ini. Four rows: host = db01, port = 5432, title = Café crème, empty = "".
[database] host = db01 port = 5432 title = Café crème empty = NB_LINE: 4
Ensuite deux sous-jobs, Écrire à la suite de coché : section "ui" avec lang = fr, puis section "database" avec port = 5433.
Then two subjobs, Append checked: section "ui" with lang = fr, then section "database" with port = 5433.
[database] host = db01 port = 5433 title = Café crème empty = [ui] lang = fr
Chaque section est suivie d'une ligne vide. La nouvelle section s'ajoute à la fin ; port change dans sa section, à sa place.
Each section is followed by an empty line. The new section is added at the end; port changes in its section, at its place.
Format .ini, Nom de section et Encodage par défaut, une ligne title = Café crème. Le tJava affiche les octets du fichier, en hexadécimal :
.ini format, default Section Name and Encoding, one row title = Café crème. The tJava prints the bytes of the file, in hexadecimal:
latin.ini: 5B 73 65 63 74 69 6F 6E 5D 0D 0A 74 69 74 6C 65 20 3D 20 43 61 66 E9 20 63 72 E8 6D 65 0D 0A 0D 0A
La section s'appelle [section] ; é et è tiennent sur un octet (E9, E8), en ISO-8859-15. Les lignes finissent par 0D 0A (CR LF) : l'essai a été fait sous Windows.
The section is called [section]; é and è take one byte (E9, E8), in ISO-8859-15. Lines end with 0D 0A (CR LF): the test was made on Windows.
Deux lignes : a = "1", b = null.
Two rows: a = "1", b = null.
[section] a = 1 b =
En .ini, la valeur nulle s'écrit vide, sans erreur. En .properties, elle arrête le job (voir les erreurs).
In .ini, the null value is written empty, with no error. In .properties, it stops the job (see the errors).
Le nom du job est remplacé par MyJob ; les traces d'exception sont abrégées. Dans les deux cas, le job s'arrête avec le code de sortie 1.
The job name is replaced with MyJob; exception traces are shortened. In both cases, the job stops with exit code 1.
Format .properties, deux lignes : a = "1", b = null.
.properties format, two rows: a = "1", b = null.
Exception in component tFileOutputProperties_1 (MyJob) java.lang.NullPointerException at java.base/java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011) at java.base/java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006) at java.base/java.util.Properties.put(Properties.java:1346) … at java.base/java.util.Properties.setProperty(Properties.java:230) …
Le fichier a été vidé au démarrage du composant et n'est jamais écrit : il reste à 0 octet. Remplacez les nulles avant, par exemple dans un tMap : row1.value == null ? "" : row1.value.
The file was emptied when the component started and is never written: it stays at 0 bytes. Replace the nulls before, for example in a tMap: row1.value == null ? "" : row1.value.
Nom de fichier "relative.properties" :
File Name "relative.properties":
Exception in component tFileOutputProperties_1 (MyJob) java.lang.NullPointerException: Cannot invoke "java.io.File.exists()" because "<local10>" is null at doci.myjob_0_1.MyJob.tFixedFlowInput_1Process(MyJob.java:679) …
Le composant cherche le dossier du fichier pour le créer ; un nom seul n'en a pas. Donnez toujours un chemin complet, par exemple context.folder + "/relative.properties".
The component looks for the folder of the file to create it; a bare name has none. Always give a full path, for example context.folder + "/relative.properties".
Une clé qui revient garde sa première place et prend la dernière valeur reçue. Pour garder chaque valeur, rendez les clés uniques en amont (db.host.1, db.host.2…).
A key that comes again keeps its first place and takes the last value received. To keep each value, make the keys unique upstream (db.host.1, db.host.2…).
Les paires sont gardées en mémoire et le fichier est écrit une fois toutes les lignes passées. Sans Écrire à la suite de, l'ancien fichier est supprimé dès le démarrage : une erreur en route le laisse vide. The pairs are kept in memory and the file is written once all the rows have gone through. Without Append, the old file is deleted at the start: an error along the way leaves it empty.
La deuxième ligne du fichier est la date de son écriture. Deux fichiers écrits à des moments différents ne sont donc pas identiques octet pour octet, même avec les mêmes paires : avant de les comparer avec tFileCompare, pensez à cette ligne, ou comparez plutôt les paires relues. The second line of the file is the date of its writing. Two files written at different times are therefore not identical byte for byte, even with the same pairs: before comparing them with tFileCompare, keep this line in mind, or compare the pairs read back instead.
Un autre job relit les paires avec tFileInputProperties, ou dans un tJava avec java.util.Properties (load) : les \uXXXX et les \: y redeviennent les caractères d'origine.
Another job reads the pairs back with tFileInputProperties, or in a tJava with java.util.Properties (load): the \uXXXX and \: become the original characters again.
tFileOutputDelimited · écrire un fichier à séparateurs, colonnes libreswrite a delimited file, any columnstFileOutputExcel · écrire un classeur Excelwrite an Excel workbooktFileCompare · comparer deux fichierscompare two filestFileExist · tester si le fichier existe avant d'écrire à la suitetest whether the file exists before appendingtFileCopy · garder une copie de l'ancien fichierkeep a copy of the old filetJavaRow · préparer les colonnes key et valueprepare the key and value columns