Answers for "how to trim whitespace in java after splitting string"

0

trim and split java

package com.zetcode;

import java.util.Arrays;

public class SplitStringTrimEx {

    public static void main(String[] args) {

        var input = " wood, falcon\t, sky, forest\n";

        var output = input.trim().split("\\s*,\\s*");

        Arrays.stream(output).forEach(System.out::println);
    }
}
Posted by: Guest on September-19-2020

Code answers related to "how to trim whitespace in java after splitting string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language