com.github.skjolber.unzip.NewlineChunkSplitter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unzip-csv Show documentation
Show all versions of unzip-csv Show documentation
Project for unzipping CSV files
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;
}
}