I know that removing whitespaces is as easy as String.trim(). But my string contains tab (\t) characters which I would like to keep.

Example:

```
"teststring\t\t\t     ".trimSpaceNotTab() => "teststring\t\t\t"

```

My current implementation is to use split();

```
String[] arr = tabbedString.split("\t");

```

Then joining them somewhere as a string.

I find this implementation slow and ugly.

Is there a better way in Java where I can retain the tabs?