FileChannel continuously write code issue
I have the following piece of code and in the **j for loop** the **out.write()** only write in **j == 0**, then the bytesThisWritten is 0.

        boolean append = true;
        FileChannel out = new FileOutputStream(dirToSave + fileName, append).getChannel();
        ByteBuffer dataBuffer = ByteBuffer.allocate(ScanDataStructConstants.NUM_DETECTORS * 4);
                    dataBuffer.order(ByteOrder.LITTLE_ENDIAN);
                    FloatBuffer floatBuffer = dataBuffer.asFloatBuffer();
                    long bytesThisWritten = 0;
                    for(int i = 0; i < ScanDataStructConstants.NUM_VIEWS_PER_ROTATION; i++)
                    {
                        if(!taskWorker.isCancelled())
                        {
                            taskWorker.setTaskProgress(i); 
                            //write auxHeader
                            AuxHeader auxHeader = auxHeaderArray.getOneAuxHeader(i);                    
                            byteWritten = byteWritten + out.write(auxHeader.getJavoAuxHeader().getCmdByteBuffer()); 
                            System.out.println("DataMgr write auxHeader i=" + i + ", byteWritten=" + byteWritten);
                            
                            //write data                               
                            for(int j = 0; j < ScanDataStructConstants.NUM_ROWS; j++)
                            {                           
                                if(!taskWorker.isCancelled())
                                {
                                    float[] oneRow = scanDataArray.getOneRowDataFromAView(i, j);                           
                                    floatBuffer.rewind();
                                    floatBuffer.put(oneRow);
                                    bytesThisWritten = out.write(dataBuffer);
                                    byteWritten = byteWritten + bytesThisWritten;
                                    if(i == 0)
                                    {
                                        System.out.println("DataMgr write data i,j=" + i + "," + j + 
                                                ", bytesThisWritten=" + bytesThisWritten + 
                                                ", byteWritten=" + byteWritten + 
                                                " oneRow.size=" + oneRow.length + 
                                                ", oneRow[0]" + oneRow[0]);
                                    }
                                }
                                else
                                {
                                    status = ReturnStatusEnum.CANCELED_FAILURE;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            status = ReturnStatusEnum.CANCELED_FAILURE;
                            break;
                        }
                    }

For the print out I know the source data is not empty:


    DataMgr write auxHeader i=0, byteWritten=4256
    DataMgr write data i,j=0,0, bytesThisWritten=3584, byteWritten=7840 oneRow.size=896, oneRow[0]-0.012269974
    DataMgr write data i,j=0,1, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.012150764
    DataMgr write data i,j=0,2, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.0056562424
    DataMgr write data i,j=0,3, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.006008148
    DataMgr write data i,j=0,4, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.0064029694
    DataMgr write data i,j=0,5, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.010842323
    DataMgr write data i,j=0,6, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.01802063
    DataMgr write data i,j=0,7, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.0023899078
    DataMgr write data i,j=0,8, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.0068216324
    DataMgr write data i,j=0,9, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.005973816
    DataMgr write data i,j=0,10, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.012469292
    DataMgr write data i,j=0,11, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.013271332
    DataMgr write data i,j=0,12, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]6.542206E-4
    DataMgr write data i,j=0,13, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.008749008
    DataMgr write data i,j=0,14, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.012054443
    DataMgr write data i,j=0,15, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.008696556

In the **i for-loop** it seems work but only in **j loop** it only write once. The FileChannel is in append mode and channel is not closed within **i loop**.  Anything wrong with my code?
FileChannel continuously write code issue
===

I have the following piece of code and in the **j for loop** the **out.write()** only write in **j == 0**, then the bytesThisWritten is 0.

        boolean append = true;
        FileChannel out = new FileOutputStream(dirToSave + fileName, append).getChannel();
        ByteBuffer dataBuffer = ByteBuffer.allocate(ScanDataStructConstants.NUM_DETECTORS * 4);
                    dataBuffer.order(ByteOrder.LITTLE_ENDIAN);
                    FloatBuffer floatBuffer = dataBuffer.asFloatBuffer();
                    long bytesThisWritten = 0;
                    for(int i = 0; i < ScanDataStructConstants.NUM_VIEWS_PER_ROTATION; i++)
                    {
                        if(!taskWorker.isCancelled())
                        {
                            taskWorker.setTaskProgress(i); 
                            //write auxHeader
                            AuxHeader auxHeader = auxHeaderArray.getOneAuxHeader(i);                    
                            byteWritten = byteWritten + out.write(auxHeader.getJavoAuxHeader().getCmdByteBuffer()); 
                            System.out.println("DataMgr write auxHeader i=" + i + ", byteWritten=" + byteWritten);
                            
                            //write data                               
                            for(int j = 0; j < ScanDataStructConstants.NUM_ROWS; j++)
                            {                           
                                if(!taskWorker.isCancelled())
                                {
                                    float[] oneRow = scanDataArray.getOneRowDataFromAView(i, j);                           
                                    floatBuffer.rewind();
                                    floatBuffer.put(oneRow);
                                    bytesThisWritten = out.write(dataBuffer);
                                    byteWritten = byteWritten + bytesThisWritten;
                                    if(i == 0)
                                    {
                                        System.out.println("DataMgr write data i,j=" + i + "," + j + 
                                                ", bytesThisWritten=" + bytesThisWritten + 
                                                ", byteWritten=" + byteWritten + 
                                                " oneRow.size=" + oneRow.length + 
                                                ", oneRow[0]" + oneRow[0]);
                                    }
                                }
                                else
                                {
                                    status = ReturnStatusEnum.CANCELED_FAILURE;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            status = ReturnStatusEnum.CANCELED_FAILURE;
                            break;
                        }
                    }

For the print out I know the source data is not empty:


    DataMgr write auxHeader i=0, byteWritten=4256
    DataMgr write data i,j=0,0, bytesThisWritten=3584, byteWritten=7840 oneRow.size=896, oneRow[0]-0.012269974
    DataMgr write data i,j=0,1, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.012150764
    DataMgr write data i,j=0,2, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.0056562424
    DataMgr write data i,j=0,3, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.006008148
    DataMgr write data i,j=0,4, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.0064029694
    DataMgr write data i,j=0,5, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.010842323
    DataMgr write data i,j=0,6, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.01802063
    DataMgr write data i,j=0,7, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.0023899078
    DataMgr write data i,j=0,8, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.0068216324
    DataMgr write data i,j=0,9, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.005973816
    DataMgr write data i,j=0,10, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.012469292
    DataMgr write data i,j=0,11, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.013271332
    DataMgr write data i,j=0,12, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]6.542206E-4
    DataMgr write data i,j=0,13, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.008749008
    DataMgr write data i,j=0,14, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.012054443
    DataMgr write data i,j=0,15, bytesThisWritten=0, byteWritten=7840 oneRow.size=896, oneRow[0]-0.008696556

In the **i for-loop** it seems work but only in **j loop** it only write once. The FileChannel is in append mode and channel is not closed within **i loop**.  Anything wrong with my code?