a=av###b=bv###c=cv map键值对 (a,av) (b,bv) (c,cv)
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger; public class Utility
{
private static Logger logger = Logger.getLogger(Utility.class); private static Integer iCode = Integer.valueOf(1020); public static HashMap<String, String> getParamByRequest(String sParam, String sValueSplit, String sParamSplit)
{
logger.debug("传递过来的参数 => " + sParam);
HashMap map = new HashMap(); if ((sParam == null) || ("".equals(sParam))) {
logger.warn("Class=>Utility Method=>getParamByRequest");
logger.warn("传递的Request参数字符串为NULL或空");
return map;
} if ((sValueSplit == null) || ("".equals(sValueSplit))) {
logger.warn("Class=>Utility Method=>getParamByRequest");
logger.warn("变量与值的分隔符号为NULL或空");
return map;
} if ((sParamSplit == null) || ("".equals(sParamSplit))) {
logger.warn("Class=>Utility Method=>getParamByRequest");
logger.warn("变量与变量之间的分隔符号为NULL或空");
return map;
} String[] sArgs = sParam.split(sParamSplit); for (int i = 0; (sArgs != null) && (i < sArgs.length); i++) {
String s = sArgs[i];
String[] sVars = s.split(sValueSplit);
if ((sVars != null) && (sVars.length > 1)) {
String name = sVars[0];
String value = sVars[1];
map.put(name, value);
}
} return map;
} public static String parseString(Boolean b)
{
String s;
String s;
if (b.booleanValue())
s = "1";
else {
s = "0";
}
return s;
} public static List getFileListByPath(String sPath)
{
List list = new ArrayList();
if ((sPath == null) || ("".equals(sPath)))
return list;
try
{
File root = new File(sPath);
File[] fileList = root.listFiles();
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isHidden()) {
continue;
}
if (fileList[i].isDirectory()) {
getChildFileListByPath(fileList[i].getPath(), list);
}
if (fileList[i].isFile()) {
String name = fileList[i].getAbsolutePath();
int index = name.lastIndexOf(File.separator);
int lastIndex = 0; if ("\\".equals(File.separator))
index++;
else if ("//".equals(File.separator)) {
index += 2;
} if ((lastIndex = name.lastIndexOf(".jsp")) > 0) {
name = name.substring(index); if ((name.indexOf("attributes_DW") != -1) ||
(name.indexOf("filters_DW") != -1) ||
(name.indexOf("buttons_DW") != -1) ||
(name.indexOf("dataWindow_DW") != -1))
continue;
Map map = new HashMap();
map.put("name", name);
map.put("value", fileList[i].getAbsolutePath());
list.add(map);
}
}
}
} catch (NullPointerException npe) {
logger.error("NullPointerException \n" + npe.getMessage());
} catch (SecurityException se) {
logger.error("SecurityException \n" + se.getMessage());
} return list;
} private static void getChildFileListByPath(String sParentPath, List<Map<String, String>> list) {
try {
File root = new File(sParentPath);
File[] fileList = root.listFiles();
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isHidden()) {
continue;
}
if (fileList[i].isDirectory()) {
getChildFileListByPath(fileList[i].getPath(), list);
}
if (fileList[i].isFile()) {
String name = fileList[i].getAbsolutePath();
int index = name.lastIndexOf(File.separator);
int lastIndex = 0; if ("\\".equals(File.separator))
index++;
else if ("//".equals(File.separator)) {
index += 2;
} if ((lastIndex = name.lastIndexOf(".jsp")) > 0) {
name = name.substring(index); if ((name.indexOf("attributes_DW") != -1) ||
(name.indexOf("filters_DW") != -1) ||
(name.indexOf("buttons_DW") != -1) ||
(name.indexOf("dataWindow_DW") != -1))
continue;
Map map = new HashMap();
map.put("name", name);
map.put("value", fileList[i].getAbsolutePath());
list.add(map);
}
}
}
} catch (NullPointerException npe) {
logger.error("NullPointerException \n" + npe.getMessage());
} catch (SecurityException se) {
logger.error("SecurityException \n" + se.getMessage());
}
} public byte[] convertObjectToByteArray(Object obj)
{
byte[] b = (byte[])null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(obj);
b = out.toByteArray(); oos.flush();
} catch (IOException e) {
logger.error("把对象串行化为字节数组时出错");
logger.error(e.getMessage());
e.printStackTrace();
}
return b;
} public Object convertByteArrayToObject(byte[] b)
{
Object obj = null;
try {
ByteArrayInputStream in = new ByteArrayInputStream(b);
ObjectInputStream ois = new ObjectInputStream(in);
obj = ois.readObject(); ois.close();
in.close();
} catch (Exception e) {
logger.error("把字节数组反串行化为对象时出错");
logger.error(e.getMessage());
}
return obj;
}
}
HashMap<String, String> map = Utility.getParamByRequest(param, "=", "###");
param="a=av###b=bv###c=cv"
分割成map (a,av) (b,bv) (c,cv)
a=av###b=bv###c=cv map键值对 (a,av) (b,bv) (c,cv)的更多相关文章
- 用字典给Model赋值并支持map键值替换
用字典给Model赋值并支持map键值替换 这个是昨天教程的升级版本,支持键值的map替换. 源码如下: NSObject+Properties.h 与 NSObject+Properties.m / ...
- java 把json对象中转成map键值对
相关:Json对象与Json字符串的转化.JSON字符串与Java对象的转换 本文的目的是把json串转成map键值对存储,而且只存储叶节点的数据 比如json数据如下: {responseHeade ...
- 如何将Map键值的下划线转为驼峰
本文不再更新,可能存在内容过时的情况,实时更新请移步我的新博客:如何将Map键值的下划线转为驼峰: 例,将HashMap实例extMap键值下划线转为驼峰: 代码: HashMap<String ...
- Java Map 键值对排序 按key排序和按Value排序
一.理论准备 Map是键值对的集合接口,它的实现类主要包括:HashMap,TreeMap,Hashtable以及LinkedHashMap等. TreeMap:基于红黑树(Red-Black tre ...
- 枚举类返回Map键值对,绑定到下拉框
有时候,页面的下拉框要显示键值对,但是不想从数据库取,此时我们可以写一个枚举类, Java后台代码 1.枚举类 import java.util.HashMap; import java.util.M ...
- 根据map键值对,生成update与select语句,单条执行语句
方法 constructUpdateSQL private static String constructUpdateSQL(String tableName, List<Map<Stri ...
- Java的map键值对的用法,map的遍历,Entry对象的使用
思路: 1.定义集合 2.存储数据 3.添加元素 4.遍历 4.1将需要遍历的集合的键封装到set集合中(这用到了entrySet方法,和Entry对象) 4.2声明迭代器或者用for增强循环 4.3 ...
- list转map 键值对
Map<Long,Account> map = new HashMap<Long,Account>(); for(int i=0;i<list.size();i++){ ...
- MyBatis返回Map键值对数据
List<Map<String, String>> getMtypeList(); <select id="getMtypeList" resultT ...
随机推荐
- 向Android模拟器中批量导入通讯录联系人
使用adb命令向Android模拟器中批量导入通讯录联系人的方法: 使用adb提供的命令, 可以非常方便地从PC中将通讯录批量导入android模拟器中. 首先要先准备好固定格式的vcf文件, 该文件 ...
- 网络请求出错:The resource could not be loaded because the App Transport
Google后查证,iOS9引入了新特性App Transport Security (ATS).详情:App Transport Security (ATS) 新特性要求App内访问的网络必须使用H ...
- 滚动轮播效果,.net 没得混看来只能去写js 了
<!DOCTYPE html> <html> <head> <title> 滚动图片 </title> <style type=&qu ...
- 一个.net程序员的安卓之旅-Eclipse设置代码智能提示功能
一个.net程序员的安卓之旅-代码智能提示功能 过完年回来就决心开始学安卓开发,就网上买了个内存条加在笔记本上(因为笔记本原来2G内存太卡了,装了vs2010.SQL Server 2008.orac ...
- 最好的cpm广告联盟哪里有
最好的cpm广告联盟哪里有,58传媒广告联盟还要提醒众位站长的是网站在经营发展中必须最大化的扩展自己的优势力量.每个网站都有属于自己的优势魅力,这些优势特点只有得到最大化的发挥才能为网站带来意想不到的 ...
- hdu 3839 Ancient Messages (dfs )
题目大意:给出一幅画,找出里面的象形文字. 要你翻译这幅画,把象形文字按字典序输出. 思路:象形文字有一些特点,分别有0个圈.1个圈.2个圈...5个圈.然后dfs或者bfs,就像油井问题一样,找出在 ...
- margin padding
margin and padding有时候可以实现相同的效果但是 用padding的场合更多 2者的区别和用法的细节我还是没掌握好
- http 协议集合,超级简单
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Web; ...
- 10-8位7段数码管驱动实验——小梅哥FPGA设计思想与验证方法视频教程配套文档
芯航线--普利斯队长精心奉献 实验目的: 1.实现FPGA驱动数码管动态显示: 2.使用In system sources and probes editor工具,输入需要显示在数码管上的的数据, ...
- 《编写可维护的JavaScript》——JavaScript编码规范(四)
注释 单行注释 单行注释以两个斜线开始,以行尾结束 单行注释有三种使用方法: 独占一行的注释,用来解释下一行代码.这行注释前总是有一个空行,且缩进层级和下一行代码保持一致. 在行尾的注释.代码结束到注 ...