question: public LocoNetMessage nextTransfer ( ) { if ( transferStart ) { transferStart = false ; transferIndex = 0 ; byte [ ] header = new byte [ 40 ] ; header [ 0 ] = ( byte ) transferHandle ; header [ 1 ] = ( byte ) ( transferContents . length & 0xFF ) ; header [ 2 ] = ( byte ) ( ( transferContents . length / 256 ) & 0xFF ) ; header [ 3 ] = ( byte ) ( ( transferContents . length / 256 / 256 ) & 0xFF ) ; header [ 4 ] = 0 ; header [ 5 ] = 0 ; header [ 6 ] = 0 ; header [ 7 ] = 0 ; for ( int i = 8 ; i < 40 ; i ++ ) { header [ i ] = 0 ; } if ( transferName . length ( ) > 32 ) { log . error ( "name " + transferName + " is too long, truncated" ) ; } for ( int i = 0 ; i < Math . min ( 32 , transferName . length ( ) ) ; i ++ ) { header [ i + 8 ] = ( byte ) transferName . charAt ( i ) ; } return getSendDataMessage ( transferType , transferHandle , header ) ; } else { int remaining = transferContents . length - transferIndex ; if ( remaining < 0 ) { log . error ( "Did not expect to find length " + transferContents . length + " and index " + transferIndex ) ; } if ( remaining <= 0 ) { return null ; } int sendSize = remaining ; if ( remaining > SENDDATASIZE ) { sendSize = SENDDATASIZE ; } byte [ ] buffer = new byte [ sendSize ] ; for ( int i = 0 ; i < sendSize ; i ++ ) { buffer [ i ] = transferContents [ transferIndex + i ] ; } transferIndex = transferIndex + sendSize ; return getSendDataMessage ( transferType , transferHandle , buffer ) ; } }
target:  Get the next message for an ongoing WAV download. You loop calling nextWavTransfer() until it says it's complete by returning null.