# Actions: Properties

install4j BeanInfo catalog. Each entry below documents a bean class that can appear inside a `<serializedBean>` element in an install4j project file.

## Contents

- [Read a properties file](#read-a-properties-file) — `com.install4j.runtime.beans.actions.properties.ReadPropertiesFileAction`
- [Remove keys from properties file](#remove-keys-from-properties-file) — `com.install4j.runtime.beans.actions.properties.RemovePropertiesAction`
- [Write properties to file](#write-properties-to-file) — `com.install4j.runtime.beans.actions.properties.WritePropertiesFileAction`

---

### Read a properties file
- **Class:** `com.install4j.runtime.beans.actions.properties.ReadPropertiesFileAction`
- **Category:** Properties files
- **Multiple instances:** yes

Read a properties file and save a java.util.Map object with the properties to an installer variable. If you use a "Write properties to file" action to write the variable back to disk, the comments on the existing property definitions will be preserved.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `file` — Properties file | File | Configuration | — | The properties file that will be read. |
| `encoding` — Encoding | [PropertiesFileEncoding](enums.md#propertiesfileencoding) | Configuration | — | Encoding for the properties file. If "java.util.Properties" is selected, the format of java.util.Properties will be emulated. For other encodings, the escaping for property values will be less aggressive. |
| `charsetName` — Character set name | String | Configuration | `encoding`=Other | The character set name as recognized by java.nio.Charset.forName(...). Values supported by all JREs include "US-ASCII" "ISO-8859-1", "UTF-8" and "UTF-16".Specifying ISO-8859-1 is not the same as selecting "java.util.Properties" for the "Encoding" property, because - except for comments - that format only writes characters from the US-ASCII character set and escapes more basic characters in property values. |
| `variableName` — Variable name | String [context=variableName] (variable→ Map) | Configuration | — | The name of the variable that will be set with an instance of java.util.Map. Enter the variable without the installer prefix and the dollar sign. |
| `merge` — Merge into existing variable | boolean | Configuration | — | If the variable already contains a value of type java.util.Map, the properties will be merged with the entries in that map. The actual map object after the action has run may be different, since install4j supplies a special map that can retain comments on property definitions. |

### Remove keys from properties file
- **Class:** `com.install4j.runtime.beans.actions.properties.RemovePropertiesAction`
- **Category:** Properties files
- **Multiple instances:** yes

Remove selected keys from a properties file. The line separator of the properties file is conserved.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `file` — Properties file | File | Configuration | — | The properties file that will modified. |
| `encoding` — Encoding | [PropertiesFileEncoding](enums.md#propertiesfileencoding) | Configuration | — | Encoding for the properties file. If "java.util.Properties" is selected, the format of java.util.Properties will be emulated. For other encodings, the escaping for property values will be less aggressive. |
| `charsetName` — Character set name | String | Configuration | `encoding`=Other | The character set name as recognized by java.nio.Charset.forName(...). Values supported by all JREs include "US-ASCII" "ISO-8859-1", "UTF-8" and "UTF-16".Specifying ISO-8859-1 is not the same as selecting "java.util.Properties" for the "Encoding" property, because - except for comments - that format only writes characters from the US-ASCII character set and escapes more basic characters in property values. |
| `keyNames` — Remove keys | String[] | Configuration | — | The names of the keys that should be removed. In the edit dialog, you have to enter one item per line. Keys that are installer variables with array or collection values (e.g. String[], Object[] or List<File>) are expanded as separate keys, this allows you to build a variable length list of keys at runtime. |

### Write properties to file
- **Class:** `com.install4j.runtime.beans.actions.properties.WritePropertiesFileAction`
- **Category:** Properties files
- **Multiple instances:** yes

Write property definitions to a properties file. The properties can come from an installer variable with a java.util.Map object, another properties file or from direct entry.If the "Merge into existing file" property is selected, the new property definitions will be added to the existing ones.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `file` — Properties file | File | Configuration | — | The properties file that will be written or modified. |
| `encoding` — Encoding | [PropertiesFileEncoding](enums.md#propertiesfileencoding) | Configuration | — | Encoding for the properties file. If "java.util.Properties" is selected, the format of java.util.Properties will be emulated. For other encodings, the escaping for property values will be less aggressive. |
| `charsetName` — Character set name | String | Configuration | `encoding`=Other | The character set name as recognized by java.nio.Charset.forName(...). Values supported by all JREs include "US-ASCII" "ISO-8859-1", "UTF-8" and "UTF-16".Specifying ISO-8859-1 is not the same as selecting "java.util.Properties" for the "Encoding" property, because - except for comments - that format only writes characters from the US-ASCII character set and escapes more basic characters in property values. |
| `lineSeparator` — Line separator | [LineSeparator](enums.md#lineseparator) | Configuration | — | The line separator that should be used for writing the properties file. |
| `merge` — Merge into existing file | boolean | Configuration | — | If selected, and the properties file already exists, the file will be read first and the new property definitions will be added to the existing ones. |
| `updateExistingKeys` — Update existing keys | boolean | Configuration | `merge`=true | If selected, the values of existing keys will be updated with the new values. |
| `updateExistingComments` — Update existing comments | boolean | Configuration | `merge`=true | If selected, the comments of existing keys will be updated with the new comments. An existing comment will not be deleted if the new comment is empty. |
| `propertiesSource` — Source of property definitions | [PropertiesSource](enums.md#propertiessource) | Configuration | — | The source of the new property definitions that should be written to the properties file. |
| `sourcePropertyDefinitions` — Property definitions | String [context=multiline] | Configuration | `propertiesSource`=Direct entry | The new property definitions that should be written to the properties file. Comment lines starting with # and empty lines can be interspersed with the property definitions. |
| `sourceFile` — Source properties file | ExternalFile [context=externalOrInternal] | Configuration | `propertiesSource`=Properties file | The source file with the new property definitions that should be written to the target properties file. The encoding must be the same as that of the target properties file. |
| `sourceVariableName` — Source variable name | String [context=variableName] (variable→ Map) | Configuration | `propertiesSource`=Installer variable | The variable name with a java.util.Map object containing the new property definitions that should be written to the properties file. If the map was read by a "Read a properties file" action, the original comments will be used. |
| `replaceInstallerVariables` — Replace installer variables | boolean | Configuration | — | If selected, installer variables written in the syntax ${installer:variableName} will be replaced with their current values for all property values. If an installer variable does not exist, an error message will be inserted. |
| `propertiesSortMode` — Sort properties | [PropertiesSortMode](enums.md#propertiessortmode) | Configuration | — | This property determines where new properties should be inserted with respect to existing properties. If the keys are sorted, then existing and new properties are sorted together. |

