All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.skjolber.unzip.NewlineChunkSplitter Maven / Gradle / Ivy

There is a newer version: 1.0.10
Show newest version
package com.github.skjolber.unzip;

public class NewlineChunkSplitter implements FileChunkSplitter {

	protected int chunkLength;
	
	public NewlineChunkSplitter(int chunkLength) {
		this.chunkLength = chunkLength;
	}

	@Override
	public int getNextChunkIndex(byte[] bytes, int index) {
		// seek backward for a newline
		while(index >= 0) {
			if(bytes[index] == '\n') {
				break;
			}
			index--;
		}
		return index;
	}

	@Override
	public int getNextChunkLength() {
		return chunkLength;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy