?? robotimage.java
字號:
import java.awt.AWTException;
import java.awt.HeadlessException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public class RobotImage {
private static Robot robot;
private static BufferedImage bufferedImage;
private static ByteArrayOutputStream byteos;
public RobotImage(){
}
public static void toFile(String filename,byte[] bodybyte){
try {
File file=new File(filename);
FileOutputStream fos=new FileOutputStream(file);
fos.write(bodybyte);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public static ByteArrayOutputStream getByteos() {
try {
robot = new Robot();
bufferedImage = robot.createScreenCapture(new Rectangle(Toolkit
.getDefaultToolkit().getScreenSize()));
byteos=new ByteArrayOutputStream();
ImageIO.write(bufferedImage, "jpeg", byteos);
return byteos;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return byteos;
}
public void setByteos(ByteArrayOutputStream byteos) {
this.byteos = byteos;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -