Answers for "how to separate strings with .trim() in java"

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 separate strings with .trim() in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language