I want to make a screenshot and then convert the image to a byte of arrays so I can send it through a BufferedOutputStream.
try
{
robot = new Robot();
screenshot = robot.createScreenCapture(new Rectangle(500,500));
imageFile = new File("image.png");
ImageInputStream iis = ImageIO.createImageInputStream(screenshot);
byte[] data = new byte[1024];
byte[] tmp = new byte[0];
byte[] myArrayImage = new byte[0];
int len = 0;
int total = 0;
while((len = iis.read(data)) != -1 ) // LINE 52 --- EXCEPTION CATCHED HERE
{
total += len;
tmp = myArrayImage;
myArrayImage = new byte[total];
System.arraycopy(tmp,0,myArrayImage,0,tmp.length);
System.arraycopy(data,0,myArrayImage,tmp.length,len);
}
ios.close();
I get this exception while running:
Exception in thread "Thread-0" java.lang.NullPointerException
at Server.run(Server.java:52)
at java.lang.Thread.run(Unknown Source)