Java 无法将Robot类的方法拍摄的屏幕截图从客户端发送到服务器

Java 无法将Robot类的方法拍摄的屏幕截图从客户端发送到服务器,java,Java,我可以使用以下代码将图片从客户端发送到服务器,但当我尝试发送CreateScreateScreenapture()方法拍摄的屏幕截图时,我可以拍摄屏幕截图并将其保存在我的PC中,但无法将其发送到服务器。谁能帮我一下吗 这些行捕获屏幕截图并将其保存在我的电脑中 Robot robot = new Robot(gdev); this.bImage = robot.createScreenCapture(rectangle); ImageIO.write(bImage, "jpg", new File

我可以使用以下代码将图片从客户端发送到服务器,但当我尝试发送CreateScreateScreenapture()方法拍摄的屏幕截图时,我可以拍摄屏幕截图并将其保存在我的PC中,但无法将其发送到服务器。谁能帮我一下吗

这些行捕获屏幕截图并将其保存在我的电脑中

Robot robot = new Robot(gdev);
this.bImage = robot.createScreenCapture(rectangle);
ImageIO.write(bImage, "jpg", new File("C:\\Users\\hp\\Desktop\\JAVA\\SocketProgrammingForReal\\Screencapture.jpg"));
它们负责发送图像

public void SendImage() throws IOException {
    ByteOutputStream byteOutput = new ByteOutputStream();
    ImageIO.write(bImage, "jpg", byteOutput);
    byte[] size = ByteBuffer.allocate(4).putInt(byteOutput.size()).array();
    dout.write(size);
    ImageIO.write(bImage, "jpg", byteOutput);
    dout.write(byteOutput.toByteArray());
    dout.flush();
}
用于接收图像并将其保存在我的电脑中的代码

DataInputStream din = new DataInputStream(server.getInputStream());
byte[] b = new byte[4];
din.read(b);
int size = ByteBuffer.wrap(b).asIntBuffer().get();
byte[] bImage = new byte[size];
din.readFully(bImage);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bImage));
ImageIO.write(image, "jpg", new File("C:\\Users\\hp\\Desktop\\JAVA\\screencapture2.jpg"));