Here you can find the source of lastIndexOfNewline(CharSequence theChars, int aStart)
public static final int lastIndexOfNewline(CharSequence theChars, int aStart)
//package com.java2s; public class Main { /**/* www. j a v a 2 s .c o m*/ * Returns index of the previous newline (or carriage-return/newline) in given chars starting at given char index. */ public static final int lastIndexOfNewline(CharSequence theChars, int aStart) { for (int i = aStart - 1; i >= 0; i--) { char c = theChars.charAt(i); if (c == '\n') return i - 1 >= 0 && theChars.charAt(i - 1) == '\r' ? (i - 1) : i; if (c == '\r') return i; } return -1; } }