Also, I expanded the Java code snippet you posted into a full program:
=== import java.awt.image.BufferedImage; import java.io.*; import java.net.*; import java.nio.file.*; import javax.imageio.ImageIO;
public class Hello { void read() { URL objUrl = this.getClass().getClassLoader().getResource("image1.jpg"); try { byte[] objBytes = Files.readAllBytes(Paths.get(objUrl.toURI())); ByteArrayInputStream bais = new ByteArrayInputStream(objBytes); BufferedImage image = ImageIO.read(bais); //>> this is where the error occurs. System.out.println("success"); } catch (Exception e) { System.out.println("Failed to create buffered image"); } }
public static void main(String[] args) { new Hello().read(); } } ===
When I run this it prints "success", so this isn't reproducing the crash for me either.
Also, I expanded the Java code snippet you posted into a full program:
=== image.BufferedI mage; ImageIO;
import java.awt.
import java.io.*;
import java.net.*;
import java.nio.file.*;
import javax.imageio.
public class Hello { ).getClassLoade r().getResource ("image1. jpg"); tes(Paths. get(objUrl. toURI() ));
ByteArrayI nputStream bais = new ByteArrayInputS tream(objBytes) ;
BufferedIm age image = ImageIO.read(bais); //>> this is where the error occurs.
System. out.println( "success" );
System. out.println( "Failed to create buffered image");
void read() {
URL objUrl = this.getClass(
try {
byte[] objBytes = Files.readAllBy
} catch (Exception e) {
}
}
public static void main(String[] args) {
new Hello().read();
}
}
===
When I run this it prints "success", so this isn't reproducing the crash for me either.