How to replace blanks in a string in Java

To replace blanks in a string in Java you can use the following snippet.

Sample Java

public static String RemoveBlanks(String input) {  
    return input.replaceAll("\\s", "");  
} 

Please Share us:
Please rate this snippet

2 thoughts on “How to replace blanks in a string in Java

Leave a Reply