通过Java几行代码截取屏幕
通过java.awt.Robot的createScreenCapture截屏。
public static void captureScreen(String fileName) throws Exception {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle);
ImageIO.write(image, "png", new File(fileName));
}
相关文档:
import java.util.regex.*;
public final class RegExpValidator
{
/**
* 验证邮箱
* @param 待验证的字符串
* @return 如果是符合的字符串,返回 <b>true </b>,否则为 <b>false </b>
*/
public static boolean isEmail(String str)
{ ......
有时,我们在写一个构造函数时,经常因为它包含众多的参数而苦恼,这时可以考虑用Builder模式来创建对象。
如,我们要设计一个营养成份的类,包含能量,蛋白质,脂肪,钙,铁,锌,维生素A, 维生素B1 ... 等,但在构造的时候,不一定每次都需要这些参数,如钙,铁,锌和维生素等是可选的,为了适应多种可能的搭配,比 ......
题目都很简单,但有时候让你用笔完整的写出来却不那么容易了.
1.遍历文件夹(被这个题目考了两次)
import java.io.File;
public class ListFile {
public static void main(String[] args) {
// TODO Auto-generated method stub
String path = "C:/Inetpub";
File f = new File(path);
list(f);
}
publ ......
java.io.InputStream的read()方法描述:
If no byte is available because the end of the stream has been reached, the value -1 is returned.
到达流的末尾真会放回-1吗?
......
Java版支付宝接口开发
需求:调用支付宝接口的接口并集成到商城
调用支付宝接口所需要的“支付宝合作伙伴id”和“支付宝安全校验码”公司都给提供好了,支付宝官方那里也有该接口的“实物商品交易服务集成技术文档”及相关的DEMO源码。公司让我用JAVA来写,终于暂时不用再写JS了,嘿嘿&hel ......