public static ValueDataWrapper readValueData ( int type , int orderNumber , File file , SpoolConfig spoolConfig ) throws IOException { ValueDataWrapper vdDataWrapper = new ValueDataWrapper ( ) ; long fileSize = file . length ( ) ; vdDataWrapper . size = fileSize ; if ( fileSize > spoolConfig . maxBufferSize ) { vdDataWrapper . value = new FilePersistedValueData ( orderNumber , file , spoolConfig ) ; } else { // JCR-2463 In case the file was renamed to be removed/changed, // but the transaction wasn't rollbacked cleanly file = fixFileName ( file ) ; FileInputStream is = new FileInputStream ( file ) ; try { byte [ ] data = new byte [ ( int ) fileSize ] ; byte [ ] buff = new byte [ ValueFileIOHelper . IOBUFFER_SIZE > fileSize ? ValueFileIOHelper . IOBUFFER_SIZE : ( int ) fileSize ] ; int rpos = 0 ; int read ; while ( ( read = is . read ( buff ) ) >= 0 ) { System . arraycopy ( buff , 0 , data , rpos , read ) ; rpos += read ; } vdDataWrapper . value = createValueData ( type , orderNumber , data ) ; } finally { is . close ( ) ; } } return vdDataWrapper ; }
Read value data from file .