我使用以下代码制作3张图片0.png,1.png和2.png,但会发生的情况是三个文件分别为1,2,3,但它们不是图像,而在picasa中则说是无效的文件。代码:
private void StartActionPerformed(java.awt.event.ActionEvent evt) {
for(int i=0; i<3; i++){
Numbers.setText(""+i);
BufferedImage image = null;
try {
image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
} catch (AWTException ex) {
Logger.getLogger(Flash_Cards.class.getName()).log(Level.SEVERE, null, ex);
}
try {
ImageIO.write(image, "png", new File("E:/Data/" + i));
} catch (IOException ex) {
Logger.getLogger(Flash_Cards.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
答案 0 :(得分:0)
将行更改为:ImageIO.write(image, "png", new File("E:/Data/abc" + i + ".png"));