string replace everything after character code example Example: replace everything before a character in java result = result.split("\n")[0];