image - Java ImageIO.write to classpath? -


i trying use imageio class save image , resource using input stream. problem keep getting nullpointerexception whenever try create input stream. if go , put image file in class path, works. here code:

imageio.write(image, "png", new file("temp.png")); inputstream imgis = aptcap.class.getresourceasstream("temp.png"); byte[] imgdata = new byte[imgis.available()]; // null here. 

i have tried specifying direct locations files on c drive both of them, still null pointer exception. rather not anyway, keep in classpath (for purposes of multi os support).

bytearrayoutputstream baos = new bytearrayoutputstream(); // create outputstream imageio.write(image, "png", baos); // write os inputstream imgis = new bytearrayinputstream(baos.tobytearray()); // grab bytes os //.. 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -