Java String split String by \r\n new line

Description

Java String split String by \r\n new line

public class Main {
   public static void main(String[] args) {
      String nixSampleLine = "Line 1 \n Line 2 \n Line 3";
      String[] lines = nixSampleLine.split("\\r?\\n");
      for (String line : lines) {
         System.out.println(">"+line+"<");
      }/*w  ww .  j a va 2 s . c  o  m*/
   }
}



PreviousNext

Related