Here you can find the source of getReverseOffsets(long fileLength, long position, byte[] buffer, int size)
public static List<Long> getReverseOffsets(long fileLength, long position, byte[] buffer, int size)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static List<Long> getReverseOffsets(long fileLength, long position, byte[] buffer, int size) { List<Long> offsets = new ArrayList<Long>(); if (size > 0) { for (int ii = size - 1; ii >= 0; ii--) { if ('\n' == buffer[ii] && (fileLength != position + ii + 1)) { offsets.add(position + ii + 1); }//from ww w . j ava2 s .co m } } return offsets; } }