I have a method as below,this method contains two arraylist ("eventList" and "emailList").
List<EmailUID> emailid=SharedEvent.getEmailUid(filter, uri, exchWD, EmailShare);
public static List<EmailUID> getEmailUid(Filter filter, String uri, NexWebDav exchWD,
List<String> emailShare)
List eventsToday = null;
List<EmailUID> arrayList = new ArrayList<EmailUID>();
List<EmailUID> emailList = new ArrayList<EmailUID>();
List<EmailUID> eventList = new ArrayList<EmailUID>();
for (String email : emailShare) {
String uris = uri + email + "/events/";
InputStream stream = null;
try {
stream = exchWD.get(uris);
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
CalendarBuilder builder = new CalendarBuilder();
net.fortuna.ical4j.model.Calendar calendar = builder.build(br);
//eventsToday.add(email);
eventsToday = (List<?>) filter.filter(calendar.getComponents(Component.VEVENT));
arrayList=getEmailUID(eventsToday,email);
emailList.addAll(arrayList);//
eventList.addAll(eventsToday);//
} catch (ParserException e) {
LOGGER.error("Parse Exception"+e.getMessage());
} finally {
IOUtils.closeQuietly(stream);
}
}
//return eventList;
return emailList;
}
How to get both the list "eventList" and "emailList"
It is not possible two return statement
from single function but you can wrap in new Map
or List
and can return two ArrayList.
public Map<String,List<EmailUID>> getList()
List<EmailUID> emailList = new ArrayList<EmailUID>();
List<EmailUID> eventList = new ArrayList<EmailUID>();
...
Map<String,List<EmailUID>> map =new HashMap();
map.put("emailList",emailList);
map.put("eventList",eventList);
return map;
}
Well if you really have to, you could wrap them up into an object, that just has 2 List fields.
Alternativly you could return a Map of the 2 Lists, with an unique key for each.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With