public static void addFileItem ( final Map < String , FileItem [ ] > files , final String name , final FileItem item ) { if ( files . containsKey ( name ) ) { // This field contains multiple values, append the new value to the existing values. FileItem [ ] oldValues = files . get ( name ) ; FileItem [ ] newValues = new FileItem [ oldValues . length + 1 ] ; System . arraycopy ( oldValues , 0 , newValues , 0 , oldValues . length ) ; newValues [ newValues . length - 1 ] = item ; files . put ( name , newValues ) ; } else { files . put ( name , new FileItem [ ] { item } ) ; } }
Add the file data to the files collection . If a file already exists with the given name then the value for this name will be an array of all registered files .