int bytesRead = 0;
// Test if fixup is still open
if (!closed) {
if (reference.getLength() > available) {
throw new HandlerException("Fixup larger than available space.");
}
// Write fixup into file
try {
// Move to position in file
randomAccessFile.seek(this.position);
// Copy data reference to position
buffer = new byte[1024];
inputStream = reference.createInputStream();
while ((bytesRead = inputStream.read(buffer, 0, 1024)) != -1) {
randomAccessFile.write(buffer, 0, bytesRead);
}
// Handle position and available placeholder bytes
position += reference.getLength();
available -= reference.getLength();
// Close the fixup
// randomAccessFile.close();
} catch (FileNotFoundException e) {
throw new HandlerException(e);
} catch (IOException e) {
throw new HandlerException(e);
}
}
}