下面列出了怎么用javax.mail.MethodNotSupportedException的API类实例代码及写法,或者点击链接到github查看源代码。
private void tryExpunge() throws MessagingException {
try {
inboxFolder.expunge();
} catch (MethodNotSupportedException mnse) {
getMonitor()
.debug(
"Expunge method not supported (e.g. POP3) - closing and reopening folder - {}",
mnse.getMessage());
inboxFolder.close(true);
reopenConnection();
}
}
@Override
public boolean delete(boolean recurse) throws MessagingException {
// Not applicable on DefaultFolder
throw new MethodNotSupportedException("Cannot delete Default Folder");
}
@Override
public boolean renameTo(Folder f) throws MessagingException {
// Not applicable on DefaultFolder
throw new MethodNotSupportedException("Cannot rename Default Folder");
}
@Override
public void appendMessages(Message[] msgs) throws MessagingException {
// Not applicable on DefaultFolder
throw new MethodNotSupportedException("Cannot append to Default Folder");
}
@Override
public Message[] expunge() throws MessagingException {
// Not applicable on DefaultFolder
throw new MethodNotSupportedException("Cannot expunge Default Folder");
}
public static <I,R,P> R invokeLocal(I i,Method method,P param) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, MethodNotSupportedException{
if(param==null){
return (R)method.invoke(i);
}
return (R)method.invoke(i,param);
}
public static <I,R,P> R invokeLocal(I i,Method method,P param) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, MethodNotSupportedException{
if(param==null){
return (R)method.invoke(i);
}
return (R)method.invoke(i,param);
}
@Override
public InputStream listCommand() throws MessagingException, IOException {
throw new MethodNotSupportedException();
}