在Java中拆分HashMap

时间:2016-05-20 10:17:29

标签: java split hashmap

我有一个像这样的HashMap:

[{cap=1, cop=1, amb=1, tota=1, ull,=1, de=1, ve=1, és=1, d'un=1, va=1, llançat=1, sola.=1, traça,=1, cega.=1, vailet=1, l'altre=1, d'esma=1, camí=1, se=1, un=1, massa=1, i=1, li=1, avançant=1, soca,=1, una=1, roc=1, el=1, buidar-li=1, vaca=1, se'n=1, la=1, en=1, altra=1, l'aigua,=1, topant=1, pel=1}, {abeurar-se=1, com=1, ses=1, no=1, amb=1, tota=1, cingles,=1, pels=1, ferm=1, solia,=1, mes=1, ve=1, és=1, tel:=1, sola.=1, ans=1, cega.=1, d'altres=1, les=1, comes,=1, font=1, a=1, companyes,=1, vegades=1, un=1, ha=1, per=1}]

我想将此地图拆分为4个部分..

我该怎么做?

谢谢!

1 个答案:

答案 0 :(得分:2)

假设您不使用// Generate a random encryption key let key = NSMutableData(length: 64)! SecRandomCopyBytes(kSecRandomDefault, key.length, UnsafeMutablePointer<UInt8>(key.mutableBytes)) // Open the encrypted Realm file let config = Realm.Configuration(encryptionKey: key) do { let realm = try Realm(configuration: config) // Use the Realm as normal let dogs = realm.objects(Dog).filter("name contains 'Fido'") } catch let error as NSError { // If the encryption key is wrong, `error` will say that it's an invalid database fatalError("Error opening realm: \(error)") } ,则需要在主Java 8上手动迭代,然后对其进行过滤以创建您的子Map,如下所示:

Map