For example I\'m extracting a text String from a text file and I need those words to form an array. However, when I do all that some words end with comma (,) or a full stop (.)
To remove the last character do as Mark Byers said
s = s.substring(0, s.length() - 1);
Additionally, another way to remove the characters you don't want would be to use the .replace(oldCharacter, newCharacter) method.
.replace(oldCharacter, newCharacter)
as in:
s = s.replace(",","");
and
s = s.replace(".","");