/** * 将两个图象叠加 * * @param Imagename_biao * @param ImgName */ public static void ImgYin(String Imagename_biao, String ImgName) { try { File _file = new File(ImgName); Image src = ImageIO.read(_file);// 读取一个文件 int wideth = src.getWidth(null);// 得到宽度 int height = src.getHeight(null);// 得到高度 BufferedImage image = new BufferedImage(wideth, height, BufferedImage.TYPE_INT_RGB);// 在内存中新建一个图象 Graphics g = image.createGraphics();// 创建画笔 g.drawImage(src, 0, 0, wideth, height, null);// 将第一张图画到这个内存图像中 // 水印文件 File _filebiao = new File(Imagename_biao); Image src_biao = ImageIO.read(_filebiao);// 读取另外一张图片 int wideth_biao = src_biao.getWidth(null); int height_biao = src_biao.getHeight(null); g.drawImage(src_biao, wideth - 10, height - 10, wideth_biao, height_biao, null);// 再画入内存图像中 g.dispose(); FileOutputStream out = new FileOutputStream(ImgName); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); encoder.encode(image);// 写入文件 // ImageIO.write(image, "JPEG", new File( // "C:/Documents and Settings/Administrator/桌面/c.jpeg"));//或者这么写也行 out.close(); } catch (Exception e) { e.printStackTrace(); } } 判断16进制 String str = "0x123fAF"; Pattern p = Pattern.compile("^[0][x][0-9a-fA-F]+$"); Matcher matcher = p.matcher(str); System.out.println(matcher.matches());