Here you can find the source of splitLines(String self)
public static List splitLines(String self)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static List splitLines(String self) { List lines = new ArrayList<String>(16); int len = self.length(); int s = 0; for (int i = 0; i < len; ++i) { int c = self.charAt(i); if (c == '\n' || c == '\r') { lines.add(self.substring(s, i)); s = i + 1;/* w ww. j a va2s . co m*/ if (c == '\r' && s < len && self.charAt(s) == '\n') { i++; s++; } } } lines.add(self.substring(s, len)); return lines; } }