File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
src/main/java/com/chainstaysoftware/filechooser/icons Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 7
7
import org .apache .commons .io .FilenameUtils ;
8
8
9
9
import java .io .File ;
10
+ import java .io .IOException ;
10
11
import java .io .InputStream ;
11
12
import java .util .HashMap ;
12
13
import java .util .Locale ;
@@ -105,12 +106,15 @@ public Image getIcon(final String resourceName) {
105
106
throw new IllegalArgumentException ("resourceName must not be null" );
106
107
}
107
108
108
- final InputStream inputStream = IconsImpl .class .getResourceAsStream (resourceName );
109
- if (inputStream == null ) {
110
- throw new IllegalArgumentException (resourceName + " is not a valid resource" );
111
- }
109
+ try ( final InputStream inputStream = IconsImpl .class .getResourceAsStream (resourceName )) {
110
+ if (inputStream == null ) {
111
+ throw new IllegalArgumentException (resourceName + " is not a valid resource" );
112
+ }
112
113
113
- return new Image (inputStream );
114
+ return new Image (inputStream );
115
+ } catch (IOException e ) {
116
+ throw new IllegalArgumentException (resourceName + " is not a valid resource" , e );
117
+ }
114
118
}
115
119
116
120
/**
You can’t perform that action at this time.
0 commit comments