java.io.FileNotFoundException: \\ABC\abc.png (The network path was not found) at java.io.RandomAccessFile.open(Native Method) at java.io.RandomAccessFile.<init>(RandomAccessFile.java:233) at javax.imageio.stream.FileImageOutputStream.<init>(FileImageOutputStream.java:69) at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(FileImageOutputStreamSpi.java:55) at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:419) at javax.imageio.ImageIO.write(ImageIO.java:1530) at javaapplication145.JavaApplication145.main(JavaApplication145.java:24) Exception in thread "main" java.lang.NullPointerException at javax.imageio.ImageIO.write(ImageIO.java:1538) at javaapplication145.JavaApplication145.main(JavaApplication145.java:24)
if (spi.getOutputClass().isInstance(output)) { try { return spi.createOutputStreamInstance(output, usecache, getCacheDirectory()); } catch (IOException e) { throw new IIOException("Can't create cache file!", e);
/** * Upon registration, this method ensures that this SPI will be invoked * before the default FileImageOutputStreamSpi * * @param registry * ServiceRegistry where this object has been registered. * @param category * a Class object indicating the registry category under * which this object has been registered. */ @SuppressWarnings("unchecked") public void onRegistration(ServiceRegistry registry, Class category) { super.onRegistration(registry, category); Object other; final Class targetClass = ImageOutputStreamSpi.class; for (Iterator i = registry.getServiceProviders(targetClass, true); i.hasNext();) { other = i.next(); // using class name to avoid warnings in JDK 11 if (other != null && other.getClass().getName().equals("com.sun.imageio.spi.FileImageOutputStreamSpi")) registry.deregisterServiceProvider(other); if (this != other) { registry.setOrdering(targetClass, this, other); } } }
/** * Upon registration, this method ensures that this SPI will be invoked * before the default FileImageOutputStreamSpi * * @param registry * ServiceRegistry where this object has been registered. * @param category * a Class object indicating the registry category under * which this object has been registered. */ @SuppressWarnings("unchecked") public void onRegistration(ServiceRegistry registry, Class category) { super.onRegistration(registry, category); Object other; final Class targetClass = ImageOutputStreamSpi.class; for (Iterator i = registry.getServiceProviders(targetClass, true); i.hasNext();) { other = i.next(); if (other instanceof FileImageOutputStreamSpi) registry.deregisterServiceProvider(other); if (this != other) { registry.setOrdering(targetClass, this, other); } } }