我无法在输出流中编写图像图标。这是我的代码。请任何人帮助我。
public ScreenSpyer(Socket socket, Robot robot, Rectangle rect) {
this.socket = socket;
this.robot = robot;
this.rectangle = rect;
start();
}
public void run(){
oos = null;
try{
oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject(rectangle);
// oos.flush();
// oos.reset();
}catch(IOException ex){
ex.printStackTrace();
}
while(continueLoop){
//Capture screen
image = robot.createScreenCapture(rectangle);
imageIcon = new ImageIcon(image);
//Send captured screen to the server
try {
System.out.println("before sending image");
System.out.println("intermidiate");
// oos.reset();
oos.writeObject(imageIcon);
System.out.println("New screenshot sent");
//oos.reset();
//oos.flush();
oos.reset();
} catch (IOException ex) {
ex.printStackTrace();
}
try{
Thread.sleep(1000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}