Bu nedenle, bir dosyaya byteArray ekleyen bir yöntem uygulamaya çalışıyorum ve herhangi bir anlam ifade ediyorsa, eklenen byteArray öğesini içeren yeni bir byteArray ayarlıyorum. Aşağıdaki kodum ancak testlerim başarısız olduğu için bir şeylerin yanlış olduğundan eminim.Bir dosyaya byteArray nasıl yazılır?
public void writeBlock(int blockNum, AbstractDBFile f, AbstractBlock b)
throws IOException {
f.setCurBlockPos(blockNum);
byte[] writeData = new byte[4096];
int currentByte = f.getCurBlockPos() * 4096;
File ourFile = new File(f.getFileName());
// Block block = new Block();
Path path = Paths.get(f.getFileName());
Files.write(path, writeData, StandardOpenOption.WRITE); //Data is Written
RandomAccessFile file = new RandomAccessFile(ourFile, "rw");
FileChannel inChannel = file.getChannel();
ByteBuffer bb = ByteBuffer.allocate(currentByte);
inChannel.write(bb);
while(inChannel.read(bb)>0){
bb.flip();
for (int i =0; i<bb.limit(); i++){
writeData[i]=bb.get();
b.setData(writeData);
}
bb.clear();
}
inChannel.close();
file.close();
}