The problem statement is: There is huge file having comma separated bytes. The file size is big enough that it cannot be stored in-memory. I want to read this file in small chunks of sliding window. I figured out how I can read file in chunks, but not am able to slide the window. For example, if file.txt has content:
{33,54,34,78,23,90,87.....}
first chunk should be : [33,54,34]
second chunk should be : [54,34,78]
third chunk should be : [34,78,23] and so on..
Here is the code to read chunk, but how I can slide window. File inputFile = new File("file.txt");
FileInputStream istream = new FileInputStream(inputFile);
BufferedInputStream in = new BufferedInputStream(istream);
int[] bytes = new byte[3];
int len;
while ((len = in.read(bytes)) != -1) {
//do some action
}