classpath-inetlib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpath-inetlib] POP3Connection.uidl()


From: petite_abeille
Subject: [Classpath-inetlib] POP3Connection.uidl()
Date: Mon, 14 Jun 2004 11:58:01 +0200

Hello,

Here is a little addition to POP3Connection which handles the no-arg UIDL command.

It returns a Map of Message Number/UID pairs.

public Map uidl() throws IOException
{
    this.send ( POP3Connection.UIDL );

    if ( this.getResponse () == OK )
    {
        Map     aMap = new LinkedHashMap();

for ( String aLine = in.readLine(); ".".equals( aLine ) == false; aLine = in.readLine() )
        {
            int     anIndex = aLine.indexOf( ' ' );
            String  aNumber = aLine.substring( 0, anIndex );
            String  anUID = aLine.substring( anIndex + 1 );

            try
            {
                aMap.put( Integer.valueOf( aNumber ), anUID );
            }
            catch (NumberFormatException anException)
            {
Logger.getInstance().log( "pop3", anException.getMessage() );
            }
        }

        if ( aMap.isEmpty() == false )
        {
            return aMap;
        }
    }

    return null;
}

Cheers,

PA.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]