String text = "I am learning Java";
// Removing All Whitespace
text.replaceAll("\\s+", "");
// Splitting a String
text.split("\\|");
text.split(Pattern.quote("|"));
See: Regex in java
Comments
String text = "I am learning Java";
// Removing All Whitespace
text.replaceAll("\\s+", "");
// Splitting a String
text.split("\\|");
text.split(Pattern.quote("|"));
See: Regex in java