To get the values for [D-1], [D-2], and so on you will first need to read the lines from the file.
If the line starts with using string.startsWith(""transmit");
then you split the string using string.split("=")
. Split it by the equal sign because that is what splits the values and the word "transmit".
Splitting a string returns a String array and you will want to get index 1 (string.split("=")1) to get [D-1]0.0 [D-2]0.0 [D-3]0.039236154
. Note: Be sure that the split has a length of at least two to avoid an array out of bounds exception.
Now you have the string [D-1]0.0 [D-2]0.0 [D-3]0.039236154
. With this split it by spaces. You can then loop through the array you got from the split and split each string by \\]
to get the [D-1] and 0.0 separated. Note: You will use a double back slash before the bracket because the bracket is a reserved char in regex.
As you split the values you can put them into a hash map and have [D-x] as a key.
Here is the example code once it is read from the file:
String start = "transmit=[D-1]0.0 [D-2]0.0 [D-3]0.039236154";
start = start.split("=")[1];
String[] split = start.split(" ");
HashMap<String, Double> transmitValues = new HashMap<String, Double>();
for(String str : split){
String[] s = str.split("\\]");
transmitValues.put(s[0] + "]", Double.parseDouble(s[1]));
}