while ((line = reader.readLine()) != null) {
if (!line.equals("")) {
int gap = line.indexOf(" ");
if (gap == -1) {
// there must be some issues in the file if no gap can be found
throw new MailboxException("Corrupted entry in uid-file " + uidList + " line " + lineNumber++);
}
Long uid = Long.valueOf(line.substring(0, gap));
String name = line.substring(gap + 1, line.length());
reverseUidMap.put(stripMetaFromName(name), uid);
}
}
String[] allFiles = (String[]) ArrayUtils.addAll(curFiles, newFiles);
for (String file : allFiles) {
MaildirMessageName messageName = newMaildirMessageName(MaildirFolder.this, file);
Long uid = reverseUidMap.get(messageName.getBaseName());
if (uid == null)
uid = getNextUid();
uidMap.put(uid, messageName);
}
pw = new PrintWriter(uidList);
pw.println(createUidListHeader());
for (Entry<Long, MaildirMessageName> entry : uidMap.entrySet())
pw.println(String.valueOf(entry.getKey()) + " " + entry.getValue().getFullName());
} catch (IOException e) {
throw new MailboxException("Unable to update uid file", e);
} finally {
IOUtils.closeQuietly(pw);
IOUtils.closeQuietly(fileReader);
IOUtils.closeQuietly(reader);
}