标签:vfp bar dbid nrv emif ccs bow gns ado
自定义jar包引用
原始java代码,代码的作用的是根据指定的字符串,生成执行长度的随机字符串
package com; import java.util.Random; public class randStr { public String random_len(int length){ String chars= "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz0123456789"; int string_length = 8; String randomstring = ""; for (int i=0; i<string_length; i++) { Random randomGenerator = new Random(); int randomInt = randomGenerator.nextInt(chars.length()); randomstring += chars.substring(randomInt,randomInt+1); } return randomstring; } public static void main(String[] args) { String result=new randStr().random_len(8); System.out.println(result); } }
通过main函数,脚本调试成功
然后通过eclipse工具将刚才的代码导出成jar包
注意:导出jar包时,一定要将main主函数删除
public static void main(String[] args) { String result=new randStr().random_len(8); System.out.println(result); }
将randStr.jar包导入
开始在BeanShell中引用
通过Beanshell代码引用
import java.util.Random; public String random_len(int length) { String chars= "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz0123456789"; int string_length = 16; String randomstring = ""; for (int i=0; i<string_length; i++) { Random randomGenerator = new Random(); int randomInt = randomGenerator.nextInt(chars.length()); randomstring += chars.substring(randomInt,randomInt+1); } return randomstring; } String result =random_len(16); log.info(result);
标签:vfp bar dbid nrv emif ccs bow gns ado
原文地址:http://www.cnblogs.com/qmfsun/p/6284156.html