Try following:
if (temp.startsWith("#")){
String[] splitted = temp.split("=");
output += splitted[1] + "\n";
}
Explanation:
To process lines only starting with desired character use String#startsWith
method. When you have string to extract values from, String#split
will split given text with character you give as method argument. So in your case, text before =
character will be in array at position 0
, text you want to print will be at position 1
.
Also note, that if your file contains many lines starting with #
, it should be wise not to concatenate strings together, but use StringBuilder / StringBuffer
to add strings together.
Hope it helps.