Category Archives: groovy

java处理图片

/**
 * Created by IntelliJ IDEA.
 * User: 274836
 * Date: 11-10-17
 * Time: 下午3:42
 * To change this template use File | Settings | File Templates.
 */

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;

public class ImageUtilsForByte {
    /**
     * 图片水印
     *
     * @param pressImg  水印图片
     * @param targetImg 目标图片
     * @param [...]

groovy 的pom文件

<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
  xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.sf</groupId>
    <artifactId>DbInterface</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>DbInterface</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>  
        <dependency>  
            <groupId>org.codehaus.groovy.maven</groupId>  
            <artifactId>gmaven-mojo</artifactId>  
            <version>1.0</version> [...]

netbean 生成pom文件(tomcat+groovy)

 
 
<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
         xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>com.sf</groupId>
    <artifactId>g</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>g Web App</name>
    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <netbeans.hint.deploy.server>Tomcat70</netbeans.hint.deploy.server>
    </properties>
 
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            [...]

Groovlets

here is also a GroovyServlet
This feature will automatically compile your .groovy source files, turn them into bytecode, load the Class and cache it until you change the source file.
Here’s a simple example to show you the kind of thing you can do from a Groovlet.
Notice the use of implicit variables to access the session, output & [...]