{
Path path = Paths.get(filePath);
try (RandomAccessFile file = new RandomAccessFile(path.toFile(), "r")) {
int bufferSize = 5 * 1024 * 1024; // 10 mb
byte[] buffer = new byte[bufferSize];
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
int bytesRead;
int totalBytes = start;
while ((bytesRead = file.read(buffer)) != -1 && totalBytes < end) {
outputStream.write(buffer, 0, bytesRead);
totalBytes += bytesRead;
}
outputStream.flush();
logger.info("output stream::: " + outputStream.toByteArray());
return outputStream.toByteArray();
}
}
Do you mean like this?
You can't just set totalBytes equal to start
Обсуждают сегодня