}
public void retr(final IoSession session, PopSession popSession, String[] args) {
String sNum = args[1];
int num = Integer.parseInt(sNum);
Message m = get(popSession, num);
if (m == null) {
popSession.reply(session, "-ERR no such message");
} else {
popSession.reply(session, "+OK " + m.size() + " octets");
Session mailSess = null;
ChunkWriter store = new ChunkWriter() {
public void newChunk(int i, byte[] data) {
IoBuffer bb = IoBuffer.wrap(data);
session.write(bb);
}
};
ChunkingOutputStream out = new ChunkingOutputStream(store, 1024);
try {
m.getResource().writeTo(out);
out.flush();
} catch (Exception e) {
log.error("exception sending message", e);
} finally {
close(out);