File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
jme3-desktop/src/main/java/com/jme3/texture/plugins Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2009-2020 jMonkeyEngine
2+ * Copyright (c) 2009-2021 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
4141import java .awt .Transparency ;
4242import java .awt .color .ColorSpace ;
4343import java .awt .image .*;
44+ import java .io .BufferedInputStream ;
4445import java .io .IOException ;
4546import java .io .InputStream ;
4647import java .nio .ByteBuffer ;
@@ -187,18 +188,13 @@ public Image load(InputStream in, boolean flipY) throws IOException{
187188 public Object load (AssetInfo info ) throws IOException {
188189 if (ImageIO .getImageReadersBySuffix (info .getKey ().getExtension ()) != null ){
189190 boolean flip = ((TextureKey ) info .getKey ()).isFlipY ();
190- InputStream in = null ;
191- try {
192- in = info .openStream ();
193- Image img = load (in , flip );
191+ try (InputStream in = info .openStream ();
192+ BufferedInputStream bin = new BufferedInputStream (in )) {
193+ Image img = load (bin , flip );
194194 if (img == null ){
195195 throw new AssetLoadException ("The given image cannot be loaded " + info .getKey ());
196196 }
197197 return img ;
198- } finally {
199- if (in != null ){
200- in .close ();
201- }
202198 }
203199 }else {
204200 throw new AssetLoadException ("The extension " + info .getKey ().getExtension () + " is not supported" );
You can’t perform that action at this time.
0 commit comments