zoukankan      html  css  js  c++  java
  • Java工具

    1. Groovy shell

    可以在Java代码里执行脚本,可以将Java方法配置在文件里

    依赖

    <dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>2.1.6</version>
    </dependency>

    Java代码

    public class GroovyShellTest {
    private static GroovyShell groovyShell = null;
    private static Script script = null;

    static {
    CompilerConfiguration config = new CompilerConfiguration();
    config.setScriptBaseClass(MyScript.class.getName());
    groovyShell = new GroovyShell(config);
    }

    public static String getScriptText(){
    return "getName(name,age,height)";
    }

    public static void main(String[] args){
    Map<String, Object> binding = new HashMap<String, Object>();
    binding.put("name", "Alex");
    binding.put("age", 27);
    binding.put("height", 172.06);
    script = groovyShell.parse(getScriptText());
    script.setBinding(new Binding(binding));
    Object val = script.run();
    System.out.println(val);
    }
    }

    public class MyScript extends Script{
    @Override
    public Object run() {
    return null;
    }

    public static String getName(String name, int age, double height){
    return "Name is " + name + "; age is " + age + "; height is " + height;
    }
    }

    2.JAXB

    Java对象和XML之间转换

    3.数据序列化

    Google Protobuf

  • 相关阅读:
    Git分支管理策略
    嵌入式文件系统构建工具 busybox / buildroot / openwrt
    nodejs与c语言交互应用实例
    python与c语言交互应用实例
    websocket programming base on nodejs
    Using Bluetooth LE with Go
    nodejs
    linux ipc/its
    SAMA5D3 Xplained Board
    BlueZ
  • 原文地址:https://www.cnblogs.com/warmingsun/p/5581701.html
Copyright © 2011-2022 走看看