code: public static List<String> splitLines(String S) {
  		List<String> V=new ArrayList<>();
  		int start=0;
  		int pos;
  		while((pos=S.indexOf('\n', start))!=-1) {
  			String line;
  			if(pos>start && S.charAt(pos-1)=='\r') line = S.substring(start, pos-1);
  			else line = S.substring(start, pos);
  			V.add(line);
  			start=pos+1;
  		}
  		int slen = S.length();
  		if(start<slen) {
  			// Ignore any trailing '\r'
  			if(S.charAt(slen-1)=='\r') slen--;
  			String line = S.substring(start, slen);
  			V.add(line);
  		}
  		return V;
  	}
docs: Splits a String into lines on any '\n' characters.  Also removes any ending '\r' characters if present