public static Map<String,Collection<String>> groupFilesByMimeType(Collection<String> attachments){
  Map<String,Collection<String>> attachmentsByMimeType=new HashMap<>();
  for (  String url : attachments) {
    String mimeType=getMimeType(url);
    if (mimeType.length() > 0) {
      Collection<String> mimeTypeList=attachmentsByMimeType.get(mimeType);
      if (mimeTypeList == null) {
        mimeTypeList=new ArrayList<>();
        attachmentsByMimeType.put(mimeType,mimeTypeList);
      }
      mimeTypeList.add(url);
    }
  }
  return attachmentsByMimeType;
}

public static Map < String , Collection < String > > groupFilesByMimeType ( Collection < String > attachments ) { Map < String , Collection < String > > attachmentsByMimeType = new HashMap < > ( ) ; for ( String url : attachments ) { String mimeType = getMimeType ( url ) ; if ( mimeType . length ( ) > 0 ) { Collection < String > mimeTypeList = attachmentsByMimeType . get ( mimeType ) ; if ( mimeTypeList == null ) { mimeTypeList = new ArrayList < > ( ) ; attachmentsByMimeType . put ( mimeType , mimeTypeList ) ; } mimeTypeList . add ( url ) ; } } return attachmentsByMimeType ; }
group given files ( urls ) into hash by mime - type
