Java Reference
In-Depth Information
// We can't just use p.writeTo() here because it doesn't
// decode the attachment. Instead we copy the input stream
// onto the output stream which does automatically decode
// Base-64, quoted printable, and a variety of other formats.
int b ;
while (( b = in . read ()) != - 1 ) out . write ( b );
out . flush ();
}
}
} catch ( MessagingException | IOException ex ) {
ex . printStackTrace ();
}
}
}
Flags
It's sometimes useful to change the flags for an entire group of messages at once. The
Folder class has three methods for doing this:
public void setFlags ( Message [] messages , Flags flag , boolean value )
throws IllegalStateException , MessagingException
public void setFlags ( int start , int end , Flags flag , boolean value )
throws IllegalStateException , MessagingException
public void setFlags ( int [] messageNumbers , Flags flag , boolean value )
throws IndexOutOfBoundsException , IllegalStateException ,
MessagingException
Ultimately, these are just conveniences. There's nothing you can do with these methods
that you can't do by setting the flags on each message individually with the set
Flags() method of the Message class. In fact, the default implementation simply invokes
that method on each message in the specified block of messages.
The Folder class also has a getPermanentFlags() method to return the flags that this
folder supports for all messages. This includes all the flags except the user-defined flags,
which are applied only to particular messages that the user has flagged. For instance,
not all folder implementations track whether messages have been answered:
public abstract Flags getPermanentFlags ()
Search WWH ::




Custom Search