also if you want to download the file as follows:
property.key.1=value of 1st key property.key.2=value of 2nd key prompt.alert = alert
etc. you can use java Properties (); Then you can instantly get the value of each key.
Explanation:
You have myTranslations.txt file. In this file, you write key / value pairs in the format:
property.key.1=value of 1st key property.key.2=value of 2nd key prompt.alert = alert
where the part before the "=" symbol is the key, and the part after is the value.
Then in your code you do:
Properties properties = new Properties(); File propertiesFile = new File (filePath); FileInputStream inputStream = null; try { inputStream = new FileInputStream(propertiesFile); properties.load(inputStream); } catch (IOException ioe) { ioe.printStackTrace(); }
where filePath is the file path above.
Then you can get the value of each key as:
properties.get("prompt.alert")
which will return a string:
alert
as in the txt file.
If this helps, please refrain.
source share