Results 1 to 3 of 3
- 09-18-2009, 11:05 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 2
- Rep Power
- 0
unreported exception IOException -- Yet I AM catching it?
Hey all, I'm an experienced programmer but new to Java. Decided to try writing a small utility in Java so it would be cross-platform without much extra work :)
I'm having some trouble though with some code that I pretty much pulled directly out of Sun's documentation.
The compiler keeps reporting "Unreported exception IOException; must be caught or declared to be thrown", yet that is exactly what I thought I was doing in the code above.Java Code:public void ListFolder() { DirectoryStream<Path> stream = null; try { stream = wFolder.newDirectoryStream(); for (Path file: stream) { System.out.println(file.getName()); } } catch (IOException e) { System.err.println(e); } finally { if (stream != null) stream.close(); } }
I am importing java.io.IOException
- 09-18-2009, 11:15 PM #2
I think you need to try/catch this. Closable throws IOExceptionJava Code:} finally { if (stream != null) stream.close(); }Last edited by mrmatt1111; 09-18-2009 at 11:18 PM.
My Hobby Project: LegacyClone
- 09-18-2009, 11:22 PM #3
Member
- Join Date
- Sep 2009
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
synchronization kid riding a swing n catching breath
By jodeen20 in forum Threads and SynchronizationReplies: 2Last Post: 09-10-2008, 01:46 PM -
Error: unreported exception java.io.IOException; ??
By jonsamwell in forum New To JavaReplies: 5Last Post: 08-24-2008, 04:11 AM -
GUI IOException
By serfster in forum New To JavaReplies: 3Last Post: 06-13-2008, 04:19 AM -
Swing - catching click button event
By Java Tip in forum Java TipReplies: 0Last Post: 03-11-2008, 11:03 PM -
AWT - catching click button event
By Java Tip in forum Java TipReplies: 0Last Post: 03-11-2008, 11:02 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks