Es muy simple de hacerlo usted mismo:
public class Substitution {
public static void main(String[] args) throws Exception {
String a = "[email protected]@ccc";
// This can be easiliy FileReader or any Reader
Reader sr = new StringReader(a);
// This can be any Writer (ie FileWriter)
Writer wr = new StringWriter();
for (;;) {
int c = sr.read();
if (c == -1) { //EOF
break;
}
if (c == '@') {
String var = readVariable(sr);
String val = getValue(var);
wr.append(val);
}
else {
wr.write(c);
}
}
}
/**
* This finds the value from Map, or somewhere
*/
private static String getValue(String var) {
return null;
}
private static String readVariable(Reader sr)throws Exception {
StringBuilder nameSB = new StringBuilder();
for (;;) {
int c = sr.read();
if (c == -1) {
throw new IllegalStateException("premature EOF.");
}
if (c == '@') {
break;
}
nameSB.append((char)c);
}
return nameSB.toString();
}
}
Tienes que pulirlo un poco, pero eso es todo.