Linked Questions

50 votes
2 answers
78k views

I upgraded to Java 8 and tried to replace a simple iteration through a Map with a new lamdba expression. The loop searches for null values and throws an exception if one is found. The old Java 7 code ...
dokaspar's user avatar
  • 8,744
0 votes
1 answer
1k views

I have two functions throwing Exception: public void foo() throws Exception { // something } public void bar() throws Exception { // something } If I combine those function calls using curly ...
osflw's user avatar
  • 129
0 votes
0 answers
543 views

when i was working on a small project of mine, i stumpled upon a weird error the Java compiler gives me, when i want to compile the code. The compilar says that i have an unhandled ...
Hakan's user avatar
  • 21
0 votes
1 answer
247 views

I have one method which throws checked exception: private void testCacheExpiration() throws InterruptedException I am trying to create a generic wrapper that will handle the exception gracefully. ...
Sagar's user avatar
  • 5,606
0 votes
0 answers
227 views

This is a follow-up to my previous, duplicate question Why is NetBeans saying "incompatible thrown types IOException in method reference"? [duplicate]. Why does NetBeans tell me "unreported exception ...
Ky -'s user avatar
  • 32.4k
0 votes
1 answer
80 views

public class PoiSheetUtil{ public Workbook mergeExcelFiles(Workbook book, Map<Integer,InputStream> inMap) throws IOException, InvalidFormatException{ inMap.forEach((k,v)->{ ...
jiangke's user avatar
  • 355
0 votes
0 answers
41 views

I have this code: private void save(List<String> items) throws IOException { try (FileWriter fileWriter = new FileWriter(file, true)) { for (String item : items) { ...
Faustas Butkus's user avatar
0 votes
0 answers
23 views

I have a bunch of methods, with similar signatures, compatible with Function, they each declare throws InterruptedException, and I put them in a list and select one by its index and call its apply(). ...
davidbak's user avatar
  • 6,098
378 votes
18 answers
170k views

How can I throw checked exceptions from inside Java 8 lambda, used in a stream for example? In other words, I want to make code like this compile: public List<Class> getClasses() throws ...
Marcelo Glasberg's user avatar
3 votes
1 answer
1k views

public List<OpBase> getHistory(ESRequest historyRequest) throws IOException, ResourceNotFoundException, URISyntaxException { String url = baseUrl + opIndex + "/_search"; String ...
Shail Patel's user avatar
  • 1,834