How to trim a string after a specific character in java July 21, 2023 by Tarik You can use: result = result.split("\n")[0];