I have a bunch of characters and want to remove everything that isn\'t a \'#\' \'.\' \'E\' and \'G\'.
I tried to use this:
if (buffer.get(buffertest) ==
You need to compare for each character individually. Assuming that buffer.get(buffertest)
returns a char
, here's how to do it:
char c = buffer.get(buffertest);
if (c == 'G' || c == 'E' || c == '#' || c == '.') {
// do something
}
Alternatively, you could do something like this:
char c = buffer.get(buffertest);
if ("GE#.".contains(Character.toString(c))) {
// do something
}