(array.size());
+ for (T t : array) {
+ newArray.add((T) (prefix + t));
+ }
+ return newArray;
+ }
+
+ /**
+ * 从0度开始为正北方
+ *
+ * Title: degrees
+ *
+ *
+ * Description:根据角度转化成中文风向,16位陆地
+ *
+ *
+ * @param degrees
+ * @return
+ * @author dorry
+ */
+ public static String degrees(Double degrees) {
+ if (348.75 <= degrees && degrees <= 360) {
+ return "北";
+ } else if (0 <= degrees && degrees <= 11.25) {
+ return "北";
+ } else if (11.25 < degrees && degrees <= 33.75) {
+ return "东北偏北";
+ } else if (33.75 < degrees && degrees <= 56.25) {
+ return "东北";
+ } else if (56.25 < degrees && degrees <= 78.75) {
+ return "东北偏东";
+ } else if (78.75 < degrees && degrees <= 101.25) {
+ return "东";
+ } else if (101.25 < degrees && degrees <= 123.75) {
+ return "东南偏东";
+ } else if (123.75 < degrees && degrees <= 146.25) {
+ return "东南";
+ } else if (146.25 < degrees && degrees <= 168.75) {
+ return "东南偏南";
+ } else if (168.75 < degrees && degrees <= 191.25) {
+ return "南";
+ } else if (191.25 < degrees && degrees <= 213.75) {
+ return "西南偏南";
+ } else if (213.75 < degrees && degrees <= 236.25) {
+ return "西南";
+ } else if (236.25 < degrees && degrees <= 258.75) {
+ return "西南偏西";
+ } else if (258.75 < degrees && degrees <= 281.25) {
+ return "西";
+ } else if (281.25 < degrees && degrees <= 303.75) {
+ return "西北偏西";
+ } else if (303.75 < degrees && degrees <= 326.25) {
+ return "西北";
+ } else if (326.25 < degrees && degrees < 348.75) {
+ return "西北偏北";
+ } else {
+ return "无风";
+ }
+ }
+
+ /**
+ * velocity模板得到字符串,模板为绝对路径文件
+ *
+ * @param data
+ * @param templateDir
+ * @return
+ */
+ //public static final String getStringFromVelocityEngineByAbsuluteDir(Map data, String templateDir) {
+ // File templateFile = new File(templateDir);
+ // if (!templateFile.exists()) {
+ // return "";
+ // }
+ // VelocityEngine ve = new VelocityEngine();
+ // Properties p = new Properties();
+ // p.put(Velocity.FILE_RESOURCE_LOADER_PATH, templateFile.getParent());
+ // ve.init(p);
+ // Template t = ve.getTemplate(templateFile.getName(), Constant.ENCODING);
+ // return getStringFromVelocityEngine(data, t, templateFile);
+ //}
+
+ /**
+ * velocity模板得到字符串,模板为相对路径文件
+ *
+ * @param data
+ * @param templateDir
+ * @return
+ */
+ //public static final String getStringFromVelocityEngineByRelationDir(Map data, String templateDir) {
+ // File templateFile = new File(templateDir);
+ // if (!templateFile.exists()) {
+ // return "";
+ // }
+ // VelocityEngine ve = new VelocityEngine();
+ // Template t = ve.getTemplate(templateFile.getPath(), Constant.ENCODING);
+ // return getStringFromVelocityEngine(data, t, templateFile);
+ //}
+
+ /**
+ * velocity模板得到字符串,实现
+ *
+ * @param data
+ * @param t
+ * @param templateFile
+ * @return
+ */
+ //private static final String getStringFromVelocityEngine(Map data, Template t, File templateFile) {
+ // VelocityContext context = new VelocityContext();
+ // if (!Util.isEmpty(data)) {
+ // for (Entry e : data.entrySet()) {
+ // context.put(e.getKey(), e.getValue());
+ // }
+ // }
+ // StringWriter writer = new StringWriter();
+ // t.merge(context, writer);
+ // log.debug(String.format("Velocity string generate for template[%s]:\n%s", templateFile.getAbsolutePath(),
+ // writer.toString()));
+ // return writer.toString();
+ //}
+
+ /**
+ * 读取配置文件中的值
+ * 前提是确认Application.java中读取配置文件的编码是ISO8859-1
+ *
+ * @param env
+ * @param key
+ * @return
+ * @throws UnsupportedEncodingException
+ */
+ //public static String getProperty(Environment env, String key) throws UnsupportedEncodingException {
+ // return new String(env.getProperty(key).getBytes("ISO8859-1"), "UTF-8");
+ //}
+
+ /**
+ * 过滤前端参数中的javaScript脚本和html标签,防止xss攻击
+ *
+ * @param value
+ * @return
+ */
+ public static String filterDangerString(String value) {
+ if (Util.isEmpty(value)) {
+ return "";
+ }
+ value = value.replaceAll("<", "<");
+ value = value.replaceAll(">", ">");
+ return value;
+ }
+
+ /**
+ * 随机生成密钥
+ *
+ * @return
+ */
+ public static String getAESRandomKey(int length) {
+
+ ArrayList strList = new ArrayList();
+
+ int begin = 97;
+ // 生成小写字母,并加入集合
+ for (int i = begin; i < begin + 26; i++) {
+ strList.add((char) i + "");
+ }
+ // 生成大写字母,并加入集合
+ begin = 65;
+ for (int i = begin; i < begin + 26; i++) {
+ strList.add((char) i + "");
+ }
+ // 将0-9的数字加入集合
+ for (int i = 0; i < 10; i++) {
+ strList.add(i + "");
+ }
+
+ Random random = new Random();
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ int size = strList.size();
+ String randomStr = strList.get(random.nextInt(size));
+ sb.append(randomStr);
+ }
+ return sb.toString();
+ }
+
+ /**
+ * 将字符串转Integer
+ *
+ * @return
+ */
+ public static Integer getInteger(String val) {
+ if (Util.isEmpty(val)) {
+ return 0;
+ }
+
+ val = val.replaceAll("[^\\-0-9]", "");
+
+ if (!isNumber(val)) {
+ return 0;
+ }
+
+ try {
+ return Integer.parseInt(val);
+ } catch (Exception e) {
+ return 0;
+ }
+ }
+
+ /**
+ * 判断一个字符串是不是数值型字符串,包括正负小数
+ *
+ * @param content
+ * @return
+ */
+ public static boolean isNumber(String content) {
+ if (Util.isEmpty(content)) {
+ return false;
+ }
+
+ String pattern = "^[\\+\\-]?[\\d]+(\\.[\\d|E]+)?$";
+ return content.matches(pattern);
+ }
+
+ /**
+ * 把输入流的内容转化成字符串
+ *
+ * @param is
+ * @return
+ * @throws IOException
+ */
+ public static String readInputStream(InputStream is) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ int length = 0;
+ byte[] buffer = new byte[1024];
+ while ((length = is.read(buffer)) != -1) {
+ baos.write(buffer, 0, length);
+ }
+ is.close();
+ baos.close();
+ return baos.toString();
+ }
+
+ /**
+ * hibernate返回的list map中的map是不能直接修改的,如果想修改,需要重新new一个新的list map
+ *
+ * @param result
+ * @return
+ */
+ public static List