Linked Questions
10 questions linked to/from Java 8 method reference unhandled exception
50
votes
2
answers
78k
views
Why can't I throw an exception in a Java 8 lambda expression? [duplicate]
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 ...
0
votes
1
answer
1k
views
Java why exception handling needed in lambda when use curly braces [duplicate]
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 ...
0
votes
0
answers
543
views
Unhandled exception, while i clearly handle the exception in Java [duplicate]
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 ...
0
votes
1
answer
247
views
Java method references while exception handling [duplicate]
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.
...
0
votes
0
answers
227
views
Why is NetBeans saying "unreported exception IOException; must be caught or declared to be thrown"? [duplicate]
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 ...
0
votes
1
answer
80
views
why I can't compile successfully with the following code? [duplicate]
public class PoiSheetUtil{
public Workbook mergeExcelFiles(Workbook book, Map<Integer,InputStream> inMap) throws IOException,
InvalidFormatException{
inMap.forEach((k,v)->{
...
0
votes
0
answers
41
views
Exceptions in java lambdas [duplicate]
I have this code:
private void save(List<String> items) throws IOException {
try (FileWriter fileWriter = new FileWriter(file, true)) {
for (String item : items) {
...
0
votes
0
answers
23
views
Method reference of method throwing checked exception triggers compilation error at point method reference is named [duplicate]
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().
...
378
votes
18
answers
170k
views
How can I throw checked exceptions from inside Java 8 lambdas/streams?
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 ...
3
votes
1
answer
1k
views
Handled Java Exception resulting in Unhandled Exception
public List<OpBase> getHistory(ESRequest historyRequest)
throws IOException, ResourceNotFoundException, URISyntaxException {
String url = baseUrl + opIndex + "/_search";
String ...