- 浏览: 123604 次
最新评论
-
gaoxikun:
看起来很齐全,很完美,但是不知道从哪里下载 。
myeclipse插件简单介绍 -
gaoxikun:
亲,能把这个集成了插件的myeclipse 6.5给我一下吗, ...
myeclipse插件简单介绍 -
hotsmile:
不错!!!!!!!!!
myeclipse插件简单介绍
public class Tools
{
static OMSLog log = Tools.getLog(Tools.class);
/**
* 文件内容集合 key :实际文件名称 value :Map<实际文件中的sheet名称, Map<表字段名称,
* String[文件中列索引,文件中实际列名]>>
*/
private static Map<String, Map<String, Map<String, String[]>>> fileMap =
null;
/**
* 名称集合 <文件名称,<实际文件中的sheet名称,表名(常量)>
*/
private static Map<String, Map<String, String>> fileNameMap = null;
/**
* 表名称对应的列集合 <表名,<列名,String[文件中列索引,文件中实际列名]>
*/
private static Map<String, Map<String, String[]>> tableMap = null;
/**
* 数据表集合 key :表名(常量) value :map<列索引,列名>
*/
private static Map<String, Map<Integer, String>> dataBaseMap = null;
/**
* 文件下的sheet名称集合(按读入顺序),导出
*/
private static Map<String, List<String>> fileSheetNameMap = null;
/**
* 支持导出文件名称集合
*/
private static List<String> exportFileNameList = null;
/**
* 插入
*/
public final static int insert = 1;
/**
* 修改
*/
public final static int update = 2;
/**
* 删除
*/
public final static int delete = 3;
/**
* 文件语言版本
*/
private static Map<String, String> fileLanguageVersion = null;
/**
* 取得日志
*
* @param clas
* @return
*/
public static OMSLog getLog(Class<?> clas)
{
String log4jName = getStringNoNull(System.getProperty("log4jname"));
if (!"".equals(log4jName))
{
PropertyConfigurator.configure(Constant.PROJECT_DIR + "/config/"
+ log4jName + ".properties");
}
return OMSLogFactory.getLog(clas);
}
/**
* 得到对应资源的资源实例
*
* @param resourceFilePath 资源文件路径
* @return ResourceBundle 资源实例
*/
public static ResourceBundle getResourceBundle(String resourceFilePath)
{
ResourceBundle resourceBundle =
ResourceBundle.getBundle(resourceFilePath);
return resourceBundle;
}
/**
* 得到对应资源的资源实例
*
* @param resourceFilePath 资源文件路径
* @return ResourceBundle 资源实例
*/
public static ResourceBundle getResourceBundle(String resourceFilePath,
Locale locale)
{
ResourceBundle resourceBundle =
ResourceBundle.getBundle(resourceFilePath, locale);
return resourceBundle;
}
/**
* 得到属性文件实例
*/
public static Properties getPropertiesByFile(String filePath)
{
InputStream inputStream = null;
Properties properties = new Properties();
try
{
File file = new File(filePath);
inputStream = new FileInputStream(file);
properties.load(inputStream);
}
catch (Exception e)
{
log.error(e.getMessage(), e);
}
finally
{
try
{
inputStream.close();
}
catch (IOException e)
{
log.error(e.getMessage(), e);
}
}
return properties;
}
/**
* 初始化导入文件功能的配置文件
*/
private static void initConfig()
{
XMLReader reader = new XMLReader();
fileMap = reader.readConfigXMLFile();
dataBaseMap = reader.readDatabaseXMLFile();
fileNameMap = reader.getSheetNameMap();
exportFileNameList = reader.getExportFileNameList();
tableMap = reader.getTableMap();
fileSheetNameMap = reader.getFileSheetNameMap();
fileLanguageVersion = reader.getFileLanguageVersion();
}
/**
* 支持导出文件名称集合
*/
public static List<String> getExportFileNameList()
{
if (exportFileNameList == null)
{
initConfig();
}
return exportFileNameList;
}
/**
* 根据表名称从database.xml文件中得到表字段集合
*
* @param tableName 表名称
* @return Map<Integer,String> 表字段集合<字段索引,字段名称>
*/
public static Map<Integer, String> getColumnMapByTableName(String tableName)
{
if (dataBaseMap == null)
{
initConfig();
}
return dataBaseMap.get(tableName.toLowerCase(Locale.getDefault()));
}
/**
* 得到对应的EXCEL文件内容集合
*
* @param fileName 文件名称
* @return Map<String, Map<String, String[]>> EXCEL文件内容集合
*/
public static Map<String, Map<String, String[]>> getSheetsByFile(
String fileName)
{
if (fileMap == null)
{
initConfig();
}
return fileMap.get(fileName.toLowerCase(Locale.getDefault()));
}
/**
* 得到对应的EXCEL文件内一个sheet页的内容集合
*
* @param fileName 文件名称
* @param sheetName sheet页名称
* @return Map<String, String[]> 一个sheet页的内容集合<表列字段名称,[文件列索引,文件列名]>
*/
public static Map<String, String[]> getColumnBySheet(String fileName,
String sheetName)
{
Map<String, Map<String, String[]>> map =
getSheetsByFile(fileName.toLowerCase(Locale.getDefault()));
return map.get(sheetName.toLowerCase(Locale.getDefault()));
}
/**
* 得到表名对应配置的列属性集合
*
* @param fileName 表名称
* @return Map<String, String[]> map<表列字段名称,[文件列索引,文件列名]>
*/
public static Map<String, String[]> getColumnByTableName(String tableName)
{
if (tableMap == null)
{
initConfig();
}
return tableMap.get(tableName.toLowerCase(Locale.getDefault()));
}
/**
* 得到EXCEL中sheet页对应的表名
*
* @param sheetName sheet页名
* @return String 表名
*/
public static String getTableName(String fileName, String sheetName)
{
if (fileNameMap == null)
{
initConfig();
}
return fileNameMap.get(fileName.toLowerCase(Locale.getDefault())).get(
sheetName.toLowerCase(Locale.getDefault()));
}
/**
* 得到EXCEL文件中sheet页的名称集合
*
* @return List<String> sheet页名集合,按读入顺序
*/
public static List<String> getSheetNameByFileName(String fileName)
{
if (fileSheetNameMap == null)
{
initConfig();
}
return fileSheetNameMap.get(fileName.toLowerCase(Locale.getDefault()));
}
/**
* 配置文件中的文件集合
*
* @return Map<实际文件中的sheet名称, Map<表字段名称, String[文件中列索引,文件中实际列名]>>
*/
public static Map<String, Map<String, Map<String, String[]>>> getFileMap()
{
if (fileMap == null)
{
initConfig();
}
return fileMap;
}
/**
* 取当前数据库中数据版本
*
* @return String 当前数据版本
*/
public static int getDataBaseVersion(int languageId)
{
int version = 0;
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
try
{
connection = JdbcUtil.getConnection();
statement = connection.createStatement();
rs =
statement
.executeQuery("select Version,languageId from version where languageId="
+ languageId);
while (rs.next())
{
String s = rs.getString("version");
version = Integer.parseInt(s);
}
}
catch (DataBaseException e)
{
log.error(e.getMessage(), e);
}
catch (SQLException e)
{
log.error(e.getMessage(), e);
}
finally
{
JdbcUtil.release(rs, statement);
}
return version;
}
/**
* 取出当前表中最大ID值
*
* @return 表中ID值
*/
public static long getTableMaxID(String tableName, String idName)
{
long id = 0;
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
try
{
connection = JdbcUtil.getConnection();
statement = connection.createStatement();
rs =
statement.executeQuery("select max(" + idName + ") from "
+ tableName);
while (rs.next())
{
id = rs.getLong(1);
}
}
catch (DataBaseException e)
{
log.error(e.getMessage(), e);
}
catch (SQLException e)
{
log.error(e.getMessage(), e);
}
finally
{
JdbcUtil.release(rs, statement);
}
id++;
return id;
}
/**
* 取出当前表中最大ID值(默认ID列名称为“id”)
*
* @return 表中ID值
*/
public static long getTableMaxID(String tableName)
{
return getTableMaxID(tableName, "id");
}
/**
* 请空表数据
*
* @param histableName 表名
* @throws DataBaseException
*/
public static void clearTableData(String tableName)
throws DataBaseException
{
String sql = "delete from " + tableName;
PreparedStatement preparedStatement = null;
try
{
preparedStatement = JdbcUtil.getConnection().prepareStatement(sql);
preparedStatement.execute();
}
catch (SQLException e)
{
throw new DataBaseException(e.getMessage(), e);
}
finally
{
JdbcUtil.release(null, preparedStatement);
}
}
/**
* 从文件路径中取出文件名称,不包含文件类型后缀
*
* @param filePath
* @return
*/
public static String getFileNameFromFilePath(String filePath)
{
String fileName =
filePath.substring(filePath.lastIndexOf("\\") + 1,
filePath.lastIndexOf("."));
// 处理有些文件配置路径为test/file.xml格式
if (fileName.indexOf("/") != -1)
{
fileName =
fileName.substring(fileName.lastIndexOf("/") + 1,
fileName.length());
}
return fileName;
}
/**
* 获取操作类型
*
* @param action
* @return
*/
public static String getOperationByAction(int action)
{
String op = "";
switch (action)
{
case insert:
op = Constant.OPERATION_CREATE;
break;
case update:
op = Constant.OPERATION_UPDATE;
break;
case delete:
op = Constant.OPERATION_DELETE;
break;
default:
break;
}
return op;
}
/**
* 获取操作类型对应值
*
* @param action
* @return
*/
public static int getActionByOperation(String operation)
{
int action = 0;
if (Constant.OPERATION_CREATE.equalsIgnoreCase(operation))
{
action = insert;
}
else if (Constant.OPERATION_UPDATE.equalsIgnoreCase(operation))
{
action = update;
}
else if (Constant.OPERATION_DELETE.equalsIgnoreCase(operation))
{
action = delete;
}
return action;
}
/**
* 得到文件中配置版本号子,如果配置不正确返-1。
*
* @return int 文件中配置版本号
*/
public static int getFileVersion(int languageId, ExcelReader excelReader)
{
int result = 0;
try
{
Locale locale = Locale.getDefault();
if (languageId == 1)
{
locale = Locale.CHINA;
}
else if (languageId == 2)
{
locale = Locale.US;
}
String fileVersion =
getResourceBundle(
"com.huawei.idesign.tablesetdatas.dataprocess.properties.tool",
locale).getString("file_version");
for (int i = 0; i < excelReader.getSheetNum(); i++)
{
String execlSheetName = excelReader.getSheetNameByIndex(i);
if (fileVersion.equalsIgnoreCase(execlSheetName))
{
List<List<String>> list = excelReader.getAllData(i);
String version = list.get(0).get(0);
result = (int) Double.parseDouble(version);
}
}
}
catch (Exception e)
{
log.error(e.getMessage(), e);
}
return result;
}
/**
* 文件语言版本
*
* @return map<文件名,语言版本>
*/
public static Map<String, String> getFileLanguageVersion()
{
if (fileLanguageVersion == null)
{
initConfig();
}
return fileLanguageVersion;
}
/**
* 将excel中的列索引转换为下标
*
* @param op
* @return
*/
public static int getIndex(String op)
{
String alphabet = "abcdefghijklmnopqrstuvwxyz";
try
{
// 如果是数字,直接返回,是字母再转换
int index = Integer.parseInt(op) - 1;
return index;
}
catch (NumberFormatException e)
{
String s = op.toLowerCase(Locale.getDefault());
if (s.length() == 1)
{
return alphabet.indexOf(s);
}
else if (s.length() == 2)
{
String fir = s.substring(0, 1);
String sed = s.substring(1, 2);
int f =
(alphabet.indexOf(fir) + 1) * 26 + alphabet.indexOf(sed);
return f;
}
else
{
return -1;
}
}
}
public static String getStringNoNull(Object str)
{
if (str == null)
{
return "";
}
else
{
return str.toString().trim();
}
}
public static String getPropertyByString(String key, String defaultValue)
{
return getStringNoNull(Tools.getPropertiesByFile(
Constant.CipherKey_FILE_PATH).getProperty(key, defaultValue));
}
/**
* add fuqiang
* 需要修改的properties键值对集合
* @param listproperties
* @see [类、类#方法、类#成员]
*/
public static void modifyProperties(Properties properties)
{
InputStream inputStream = null;
OutputStream fos = null;
Properties tempProper = new Properties();
File file = new File(Constant.CipherKey_FILE_PATH);
try
{
inputStream = new FileInputStream(file);
tempProper.load(inputStream);
fos = new FileOutputStream(file);
tempProper.setProperty("userName", properties.getProperty("userName"));
tempProper.setProperty("passwd", properties.getProperty("passwd"));
tempProper.store(fos, null);
}
catch (Exception e)
{
log.error("Tools calss Setting PropertyValue is fail!"+e.getMessage());
}finally
{
try
{
if(null != fos)
{
fos.close();
}
if(null != inputStream)
{
inputStream.close();
}
}
catch (IOException e)
{
log.error("Tools calss close OutputStream fial!"+e.getMessage());
}
}
}
public static int getPropertyByInt(String key, int defaultValue)
{
int result = defaultValue;
String strValue = getStringNoNull(Tools.getPropertiesByFile(
Constant.CipherKey_FILE_PATH).getProperty(key));
try {
result = Integer.parseInt(strValue);
} catch (NumberFormatException e) {
log.error(e.getMessage());
}
return result;
}
public static boolean authorise()
{
/**
* add fuqiang
* 增加用户鉴权
*/
boolean isLogin = false;
try
{
//得到解密后的passwd值
String tempPasswd = CipherUtil.decryptPwd(getPropertyByString("passwd",""));
//得到配置文件中的user值
String tempUser = getPropertyByString("userName","");
//得到配置的URL
String tempUrl = getPropertyByString("url","");
isLogin = HttpValidate.validConnector(tempUser, tempPasswd, tempUrl);
// if("admin".equals(tempUser) && "admin".equals(tempPasswd))
// {
// isLogin = true;
// }
}
catch (Exception e1)
{
log.error("CFGSelectDialog calss Getting PropertyValue is fail!"+e1.getMessage());
}
return isLogin;
}
==================================================================================================================
public class XMLReader
{
OMSLog log = Tools.getLog(this.getClass());
private Map<String, Map<String, String>> fileNameMap =
new HashMap<String, Map<String, String>>();
private Map<String, Map<String, String[]>> tableMap =
new HashMap<String, Map<String, String[]>>();
private Map<String, List<String>> fileSheetNameMap =
new HashMap<String, List<String>>();
/**
* 支持导出文件名称集合
*/
List<String> exportFileNameList=new ArrayList<String>();
/**
* 文件语言版本
*/
Map<String, String> fileLanguageVersion = new HashMap<String, String>();
/**
* 文件语言版本
*/
public Map<String, String> getFileLanguageVersion()
{
return fileLanguageVersion;
}
/**
* 支持导出文件名称集合
*/
public List<String> getExportFileNameList()
{
return exportFileNameList;
}
/**
* 文件下的sheet名称集合(按读入顺序)
*
* @return
*/
public Map<String, List<String>> getFileSheetNameMap()
{
return fileSheetNameMap;
}
/**
* 表名对应的Sheet页名称
*
* @return Map<文件名称,<Sheet页名称,数据库表名>>
*/
public Map<String, Map<String, String>> getSheetNameMap()
{
return fileNameMap;
}
public Map<String, Map<String, String[]>> getTableMap()
{
return this.tableMap;
}
/**
* 解析Sheet页节点下的所有列配置
*
* @param columnNodes 列节点List
* @return Map<数据库表字段,对应Sheet页中的列名>
*/
private Map<String, String[]> readcolumnNode(NodeList columnNodes)
{
Map<String, String[]> columnMap = new HashMap<String, String[]>();
for (int k = 0; k < columnNodes.getLength(); k++)
{
Node columnNode = columnNodes.item(k);
if (columnNode.getNodeType() == 1)
{
String tablecolumn =
columnNode.getAttributes().getNamedItem("tablecolumn")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
String columnName =
columnNode.getAttributes().getNamedItem("columnname")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
String index =
columnNode.getAttributes().getNamedItem("index")
.getNodeValue().trim();
columnMap.put(tablecolumn, new String[] { index, columnName });
}
}
return columnMap;
}
/**
* 解析表节点下的所有列配置
*
* @param columnNodes 列节点List
* @return Map<列索引,列名>
*/
private Map<Integer, String> readColumnNode(NodeList columnNodes)
{
Map<Integer, String> columnMap = new HashMap<Integer, String>();
for (int k = 0; k < columnNodes.getLength(); k++)
{
Node columnNode = columnNodes.item(k);
if (columnNode.getNodeType() == 1)
{
String columnName =
columnNode.getAttributes().getNamedItem("name")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
String index =
columnNode.getAttributes().getNamedItem("index")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
columnMap.put(Integer.parseInt(index), columnName);
}
}
return columnMap;
}
/**
* 解析EXCEL文件配置文件
*
* @return Map<EXCEL文件名称,Map<Sheet页名称, Map<数据库表字段,对应Sheet页中的列名>>>
*/
public Map<String, Map<String, Map<String, String[]>>> readConfigXMLFile()
{
String filePath =Constant.PROJECT_DIR+ Constant.CONFIG_FILE_PATH;
DocumentBuilder builder;
Document doc;
Map<String, Map<String, Map<String, String[]>>> fileMap =
new HashMap<String, Map<String, Map<String, String[]>>>();
try
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
log.info("Load file [" + filePath + "]");
doc = builder.parse(new File(filePath));
Element root = doc.getDocumentElement();
NodeList nodeList = root.getElementsByTagName("excelfile");
for (int i = 0; i < nodeList.getLength(); i++)
{
Node excelfileNode = nodeList.item(i);
if (excelfileNode.getNodeType() == 1)
{
String excelfileName =
excelfileNode.getAttributes().getNamedItem("filename")
.getNodeValue().trim()
.toLowerCase(Locale.getDefault());
String isExport= excelfileNode.getAttributes().getNamedItem("supportExport")
.getNodeValue().trim();
String language= excelfileNode.getAttributes().getNamedItem("language")
.getNodeValue().trim();
//保存支持导出文件名称
if (Boolean.valueOf(isExport))
{
exportFileNameList.add(excelfileName);
}
fileLanguageVersion.put(excelfileName, language);
NodeList sheetNodes = excelfileNode.getChildNodes();
fileMap.put(excelfileName,
readSheetNode(excelfileName, sheetNodes));
}
}
}
catch (Exception e)
{
log.error(e.getMessage(), e);
}
return fileMap;
}
/**
* 读取数据库配置表信息
*
* @return Map<表名,Map<列索引,列名>>
*/
public Map<String, Map<Integer, String>> readDatabaseXMLFile()
{
String filePath = Constant.PROJECT_DIR+Constant.DATABASE_FILE_PATH;
DocumentBuilder builder;
Document doc;
Map<String, Map<Integer, String>> fileMap =
new HashMap<String, Map<Integer, String>>();
try
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
log.info("Load file [" + filePath + "]");
doc = builder.parse(new File(filePath));
Element root = doc.getDocumentElement();
NodeList nodeList = root.getElementsByTagName("table");
for (int i = 0; i < nodeList.getLength(); i++)
{
Node excelfileNode = nodeList.item(i);
if (excelfileNode.getNodeType() == 1)
{
String tableName =
excelfileNode.getAttributes().getNamedItem("name")
.getNodeValue().trim()
.toLowerCase(Locale.getDefault());
NodeList columnNodes = excelfileNode.getChildNodes();
fileMap.put(tableName, readColumnNode(columnNodes));
}
}
}
catch (Exception e)
{
log.error(e.getMessage(), e);
}
return fileMap;
}
/**
* 解析文件节点下的所有Sheet页配置
*
* @param columnNodes Sheet页节点List
* @return Map<Sheet页名称, Map<数据库表字段,对应Sheet页中的列名>>
*/
private Map<String, Map<String, String[]>> readSheetNode(
String excelfileName, NodeList sheetNodes)
{
Map<String, Map<String, String[]>> sheetMap =
new HashMap<String, Map<String, String[]>>();
Map<String, String> sheetNameMap = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
for (int k = 0; k < sheetNodes.getLength(); k++)
{
Node sheetNode = sheetNodes.item(k);
if (sheetNode.getNodeType() == 1)
{
String tableName =
sheetNode.getAttributes().getNamedItem("tableName")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
String sheetName =
sheetNode.getAttributes().getNamedItem("sheetname")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
sheetNameMap.put(sheetName, tableName);
NodeList columnNodes = sheetNode.getChildNodes();
Map<String, String[]> columnMap = readcolumnNode(columnNodes);
sheetMap.put(sheetName, columnMap);
if (tableMap.containsKey(tableName))
{
tableName = tableName + "_" + sheetName;
}
tableMap.put(tableName, columnMap);
list.add(sheetName);
}
}
fileNameMap.put(excelfileName, sheetNameMap);
fileSheetNameMap.put(excelfileName, list);
return sheetMap;
}
=========================================================================================================================
加密与解密
public class CipherUtil
{
private static OMSLog log = Tools.getLog(CipherUtil.class);
private static String CIPHER_TYPE = "AES";
private static String CIPHER_MODE = "AES/ECB/PKCS5Padding";
/**
* 用AES算法解密
*/
public static String decryptPwd(String input)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IOException, IllegalBlockSizeException,
BadPaddingException
{
return decryptPwd(input,false);
}
/**
* 服务端用AES算法解密
*/
public static String decryptPwd(String input,boolean isServer)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IOException, IllegalBlockSizeException,
BadPaddingException
{
byte[] keydata = isServer?getKey(Constant.CipherKey_SERVER_FILE_PATH):getKey();
SecretKeySpec key = new SecretKeySpec(keydata, 0, 16, CIPHER_TYPE);
Cipher cipher = Cipher.getInstance(CIPHER_MODE);
cipher.init(Cipher.DECRYPT_MODE, key);
BASE64Decoder decoder = new BASE64Decoder();
byte[] data = decoder.decodeBuffer(input);
byte[] decryptData = cipher.doFinal(data, 0, data.length);
return new String(decryptData);
}
/**
* 用AES算法加密
*
* @throws IOException
*/
public static String encryptPwd(String input)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException,
IOException
{
SecretKeySpec key = new SecretKeySpec(getKey(), 0, 16, CIPHER_TYPE);
Cipher cipher = Cipher.getInstance(CIPHER_MODE);
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] bs = cipher.doFinal(input.getBytes());
return new sun.misc.BASE64Encoder().encode(bs);
}
/**
* 生成AES加密密钥
*
* @throws IOException
* @throws NoSuchPaddingException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws BadPaddingException
* @throws IllegalBlockSizeException
*/
private static byte[] getKey()
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException,
IOException
{
return getKey(Constant.CipherKey_FILE_PATH);
}
/**
* 生成AES加密密钥
*
* @throws IOException
* @throws NoSuchPaddingException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws BadPaddingException
* @throws IllegalBlockSizeException
*/
private static byte[] getKey(String path)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException,
IOException
{
String initKey = "ci~+Ides5ign*1=)";
String input =
Tools.getStringNoNull(Tools.getPropertiesByFile(
path).getProperty("CipherKey"));
SecretKeySpec key = new SecretKeySpec(initKey.getBytes(), CIPHER_TYPE);
Cipher cipher = Cipher.getInstance(CIPHER_MODE);
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] bs = cipher.doFinal(input.getBytes());
return bs;
}
=========================
http://www.iteye.com/topic/1122076
{
static OMSLog log = Tools.getLog(Tools.class);
/**
* 文件内容集合 key :实际文件名称 value :Map<实际文件中的sheet名称, Map<表字段名称,
* String[文件中列索引,文件中实际列名]>>
*/
private static Map<String, Map<String, Map<String, String[]>>> fileMap =
null;
/**
* 名称集合 <文件名称,<实际文件中的sheet名称,表名(常量)>
*/
private static Map<String, Map<String, String>> fileNameMap = null;
/**
* 表名称对应的列集合 <表名,<列名,String[文件中列索引,文件中实际列名]>
*/
private static Map<String, Map<String, String[]>> tableMap = null;
/**
* 数据表集合 key :表名(常量) value :map<列索引,列名>
*/
private static Map<String, Map<Integer, String>> dataBaseMap = null;
/**
* 文件下的sheet名称集合(按读入顺序),导出
*/
private static Map<String, List<String>> fileSheetNameMap = null;
/**
* 支持导出文件名称集合
*/
private static List<String> exportFileNameList = null;
/**
* 插入
*/
public final static int insert = 1;
/**
* 修改
*/
public final static int update = 2;
/**
* 删除
*/
public final static int delete = 3;
/**
* 文件语言版本
*/
private static Map<String, String> fileLanguageVersion = null;
/**
* 取得日志
*
* @param clas
* @return
*/
public static OMSLog getLog(Class<?> clas)
{
String log4jName = getStringNoNull(System.getProperty("log4jname"));
if (!"".equals(log4jName))
{
PropertyConfigurator.configure(Constant.PROJECT_DIR + "/config/"
+ log4jName + ".properties");
}
return OMSLogFactory.getLog(clas);
}
/**
* 得到对应资源的资源实例
*
* @param resourceFilePath 资源文件路径
* @return ResourceBundle 资源实例
*/
public static ResourceBundle getResourceBundle(String resourceFilePath)
{
ResourceBundle resourceBundle =
ResourceBundle.getBundle(resourceFilePath);
return resourceBundle;
}
/**
* 得到对应资源的资源实例
*
* @param resourceFilePath 资源文件路径
* @return ResourceBundle 资源实例
*/
public static ResourceBundle getResourceBundle(String resourceFilePath,
Locale locale)
{
ResourceBundle resourceBundle =
ResourceBundle.getBundle(resourceFilePath, locale);
return resourceBundle;
}
/**
* 得到属性文件实例
*/
public static Properties getPropertiesByFile(String filePath)
{
InputStream inputStream = null;
Properties properties = new Properties();
try
{
File file = new File(filePath);
inputStream = new FileInputStream(file);
properties.load(inputStream);
}
catch (Exception e)
{
log.error(e.getMessage(), e);
}
finally
{
try
{
inputStream.close();
}
catch (IOException e)
{
log.error(e.getMessage(), e);
}
}
return properties;
}
/**
* 初始化导入文件功能的配置文件
*/
private static void initConfig()
{
XMLReader reader = new XMLReader();
fileMap = reader.readConfigXMLFile();
dataBaseMap = reader.readDatabaseXMLFile();
fileNameMap = reader.getSheetNameMap();
exportFileNameList = reader.getExportFileNameList();
tableMap = reader.getTableMap();
fileSheetNameMap = reader.getFileSheetNameMap();
fileLanguageVersion = reader.getFileLanguageVersion();
}
/**
* 支持导出文件名称集合
*/
public static List<String> getExportFileNameList()
{
if (exportFileNameList == null)
{
initConfig();
}
return exportFileNameList;
}
/**
* 根据表名称从database.xml文件中得到表字段集合
*
* @param tableName 表名称
* @return Map<Integer,String> 表字段集合<字段索引,字段名称>
*/
public static Map<Integer, String> getColumnMapByTableName(String tableName)
{
if (dataBaseMap == null)
{
initConfig();
}
return dataBaseMap.get(tableName.toLowerCase(Locale.getDefault()));
}
/**
* 得到对应的EXCEL文件内容集合
*
* @param fileName 文件名称
* @return Map<String, Map<String, String[]>> EXCEL文件内容集合
*/
public static Map<String, Map<String, String[]>> getSheetsByFile(
String fileName)
{
if (fileMap == null)
{
initConfig();
}
return fileMap.get(fileName.toLowerCase(Locale.getDefault()));
}
/**
* 得到对应的EXCEL文件内一个sheet页的内容集合
*
* @param fileName 文件名称
* @param sheetName sheet页名称
* @return Map<String, String[]> 一个sheet页的内容集合<表列字段名称,[文件列索引,文件列名]>
*/
public static Map<String, String[]> getColumnBySheet(String fileName,
String sheetName)
{
Map<String, Map<String, String[]>> map =
getSheetsByFile(fileName.toLowerCase(Locale.getDefault()));
return map.get(sheetName.toLowerCase(Locale.getDefault()));
}
/**
* 得到表名对应配置的列属性集合
*
* @param fileName 表名称
* @return Map<String, String[]> map<表列字段名称,[文件列索引,文件列名]>
*/
public static Map<String, String[]> getColumnByTableName(String tableName)
{
if (tableMap == null)
{
initConfig();
}
return tableMap.get(tableName.toLowerCase(Locale.getDefault()));
}
/**
* 得到EXCEL中sheet页对应的表名
*
* @param sheetName sheet页名
* @return String 表名
*/
public static String getTableName(String fileName, String sheetName)
{
if (fileNameMap == null)
{
initConfig();
}
return fileNameMap.get(fileName.toLowerCase(Locale.getDefault())).get(
sheetName.toLowerCase(Locale.getDefault()));
}
/**
* 得到EXCEL文件中sheet页的名称集合
*
* @return List<String> sheet页名集合,按读入顺序
*/
public static List<String> getSheetNameByFileName(String fileName)
{
if (fileSheetNameMap == null)
{
initConfig();
}
return fileSheetNameMap.get(fileName.toLowerCase(Locale.getDefault()));
}
/**
* 配置文件中的文件集合
*
* @return Map<实际文件中的sheet名称, Map<表字段名称, String[文件中列索引,文件中实际列名]>>
*/
public static Map<String, Map<String, Map<String, String[]>>> getFileMap()
{
if (fileMap == null)
{
initConfig();
}
return fileMap;
}
/**
* 取当前数据库中数据版本
*
* @return String 当前数据版本
*/
public static int getDataBaseVersion(int languageId)
{
int version = 0;
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
try
{
connection = JdbcUtil.getConnection();
statement = connection.createStatement();
rs =
statement
.executeQuery("select Version,languageId from version where languageId="
+ languageId);
while (rs.next())
{
String s = rs.getString("version");
version = Integer.parseInt(s);
}
}
catch (DataBaseException e)
{
log.error(e.getMessage(), e);
}
catch (SQLException e)
{
log.error(e.getMessage(), e);
}
finally
{
JdbcUtil.release(rs, statement);
}
return version;
}
/**
* 取出当前表中最大ID值
*
* @return 表中ID值
*/
public static long getTableMaxID(String tableName, String idName)
{
long id = 0;
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
try
{
connection = JdbcUtil.getConnection();
statement = connection.createStatement();
rs =
statement.executeQuery("select max(" + idName + ") from "
+ tableName);
while (rs.next())
{
id = rs.getLong(1);
}
}
catch (DataBaseException e)
{
log.error(e.getMessage(), e);
}
catch (SQLException e)
{
log.error(e.getMessage(), e);
}
finally
{
JdbcUtil.release(rs, statement);
}
id++;
return id;
}
/**
* 取出当前表中最大ID值(默认ID列名称为“id”)
*
* @return 表中ID值
*/
public static long getTableMaxID(String tableName)
{
return getTableMaxID(tableName, "id");
}
/**
* 请空表数据
*
* @param histableName 表名
* @throws DataBaseException
*/
public static void clearTableData(String tableName)
throws DataBaseException
{
String sql = "delete from " + tableName;
PreparedStatement preparedStatement = null;
try
{
preparedStatement = JdbcUtil.getConnection().prepareStatement(sql);
preparedStatement.execute();
}
catch (SQLException e)
{
throw new DataBaseException(e.getMessage(), e);
}
finally
{
JdbcUtil.release(null, preparedStatement);
}
}
/**
* 从文件路径中取出文件名称,不包含文件类型后缀
*
* @param filePath
* @return
*/
public static String getFileNameFromFilePath(String filePath)
{
String fileName =
filePath.substring(filePath.lastIndexOf("\\") + 1,
filePath.lastIndexOf("."));
// 处理有些文件配置路径为test/file.xml格式
if (fileName.indexOf("/") != -1)
{
fileName =
fileName.substring(fileName.lastIndexOf("/") + 1,
fileName.length());
}
return fileName;
}
/**
* 获取操作类型
*
* @param action
* @return
*/
public static String getOperationByAction(int action)
{
String op = "";
switch (action)
{
case insert:
op = Constant.OPERATION_CREATE;
break;
case update:
op = Constant.OPERATION_UPDATE;
break;
case delete:
op = Constant.OPERATION_DELETE;
break;
default:
break;
}
return op;
}
/**
* 获取操作类型对应值
*
* @param action
* @return
*/
public static int getActionByOperation(String operation)
{
int action = 0;
if (Constant.OPERATION_CREATE.equalsIgnoreCase(operation))
{
action = insert;
}
else if (Constant.OPERATION_UPDATE.equalsIgnoreCase(operation))
{
action = update;
}
else if (Constant.OPERATION_DELETE.equalsIgnoreCase(operation))
{
action = delete;
}
return action;
}
/**
* 得到文件中配置版本号子,如果配置不正确返-1。
*
* @return int 文件中配置版本号
*/
public static int getFileVersion(int languageId, ExcelReader excelReader)
{
int result = 0;
try
{
Locale locale = Locale.getDefault();
if (languageId == 1)
{
locale = Locale.CHINA;
}
else if (languageId == 2)
{
locale = Locale.US;
}
String fileVersion =
getResourceBundle(
"com.huawei.idesign.tablesetdatas.dataprocess.properties.tool",
locale).getString("file_version");
for (int i = 0; i < excelReader.getSheetNum(); i++)
{
String execlSheetName = excelReader.getSheetNameByIndex(i);
if (fileVersion.equalsIgnoreCase(execlSheetName))
{
List<List<String>> list = excelReader.getAllData(i);
String version = list.get(0).get(0);
result = (int) Double.parseDouble(version);
}
}
}
catch (Exception e)
{
log.error(e.getMessage(), e);
}
return result;
}
/**
* 文件语言版本
*
* @return map<文件名,语言版本>
*/
public static Map<String, String> getFileLanguageVersion()
{
if (fileLanguageVersion == null)
{
initConfig();
}
return fileLanguageVersion;
}
/**
* 将excel中的列索引转换为下标
*
* @param op
* @return
*/
public static int getIndex(String op)
{
String alphabet = "abcdefghijklmnopqrstuvwxyz";
try
{
// 如果是数字,直接返回,是字母再转换
int index = Integer.parseInt(op) - 1;
return index;
}
catch (NumberFormatException e)
{
String s = op.toLowerCase(Locale.getDefault());
if (s.length() == 1)
{
return alphabet.indexOf(s);
}
else if (s.length() == 2)
{
String fir = s.substring(0, 1);
String sed = s.substring(1, 2);
int f =
(alphabet.indexOf(fir) + 1) * 26 + alphabet.indexOf(sed);
return f;
}
else
{
return -1;
}
}
}
public static String getStringNoNull(Object str)
{
if (str == null)
{
return "";
}
else
{
return str.toString().trim();
}
}
public static String getPropertyByString(String key, String defaultValue)
{
return getStringNoNull(Tools.getPropertiesByFile(
Constant.CipherKey_FILE_PATH).getProperty(key, defaultValue));
}
/**
* add fuqiang
* 需要修改的properties键值对集合
* @param listproperties
* @see [类、类#方法、类#成员]
*/
public static void modifyProperties(Properties properties)
{
InputStream inputStream = null;
OutputStream fos = null;
Properties tempProper = new Properties();
File file = new File(Constant.CipherKey_FILE_PATH);
try
{
inputStream = new FileInputStream(file);
tempProper.load(inputStream);
fos = new FileOutputStream(file);
tempProper.setProperty("userName", properties.getProperty("userName"));
tempProper.setProperty("passwd", properties.getProperty("passwd"));
tempProper.store(fos, null);
}
catch (Exception e)
{
log.error("Tools calss Setting PropertyValue is fail!"+e.getMessage());
}finally
{
try
{
if(null != fos)
{
fos.close();
}
if(null != inputStream)
{
inputStream.close();
}
}
catch (IOException e)
{
log.error("Tools calss close OutputStream fial!"+e.getMessage());
}
}
}
public static int getPropertyByInt(String key, int defaultValue)
{
int result = defaultValue;
String strValue = getStringNoNull(Tools.getPropertiesByFile(
Constant.CipherKey_FILE_PATH).getProperty(key));
try {
result = Integer.parseInt(strValue);
} catch (NumberFormatException e) {
log.error(e.getMessage());
}
return result;
}
public static boolean authorise()
{
/**
* add fuqiang
* 增加用户鉴权
*/
boolean isLogin = false;
try
{
//得到解密后的passwd值
String tempPasswd = CipherUtil.decryptPwd(getPropertyByString("passwd",""));
//得到配置文件中的user值
String tempUser = getPropertyByString("userName","");
//得到配置的URL
String tempUrl = getPropertyByString("url","");
isLogin = HttpValidate.validConnector(tempUser, tempPasswd, tempUrl);
// if("admin".equals(tempUser) && "admin".equals(tempPasswd))
// {
// isLogin = true;
// }
}
catch (Exception e1)
{
log.error("CFGSelectDialog calss Getting PropertyValue is fail!"+e1.getMessage());
}
return isLogin;
}
==================================================================================================================
public class XMLReader
{
OMSLog log = Tools.getLog(this.getClass());
private Map<String, Map<String, String>> fileNameMap =
new HashMap<String, Map<String, String>>();
private Map<String, Map<String, String[]>> tableMap =
new HashMap<String, Map<String, String[]>>();
private Map<String, List<String>> fileSheetNameMap =
new HashMap<String, List<String>>();
/**
* 支持导出文件名称集合
*/
List<String> exportFileNameList=new ArrayList<String>();
/**
* 文件语言版本
*/
Map<String, String> fileLanguageVersion = new HashMap<String, String>();
/**
* 文件语言版本
*/
public Map<String, String> getFileLanguageVersion()
{
return fileLanguageVersion;
}
/**
* 支持导出文件名称集合
*/
public List<String> getExportFileNameList()
{
return exportFileNameList;
}
/**
* 文件下的sheet名称集合(按读入顺序)
*
* @return
*/
public Map<String, List<String>> getFileSheetNameMap()
{
return fileSheetNameMap;
}
/**
* 表名对应的Sheet页名称
*
* @return Map<文件名称,<Sheet页名称,数据库表名>>
*/
public Map<String, Map<String, String>> getSheetNameMap()
{
return fileNameMap;
}
public Map<String, Map<String, String[]>> getTableMap()
{
return this.tableMap;
}
/**
* 解析Sheet页节点下的所有列配置
*
* @param columnNodes 列节点List
* @return Map<数据库表字段,对应Sheet页中的列名>
*/
private Map<String, String[]> readcolumnNode(NodeList columnNodes)
{
Map<String, String[]> columnMap = new HashMap<String, String[]>();
for (int k = 0; k < columnNodes.getLength(); k++)
{
Node columnNode = columnNodes.item(k);
if (columnNode.getNodeType() == 1)
{
String tablecolumn =
columnNode.getAttributes().getNamedItem("tablecolumn")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
String columnName =
columnNode.getAttributes().getNamedItem("columnname")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
String index =
columnNode.getAttributes().getNamedItem("index")
.getNodeValue().trim();
columnMap.put(tablecolumn, new String[] { index, columnName });
}
}
return columnMap;
}
/**
* 解析表节点下的所有列配置
*
* @param columnNodes 列节点List
* @return Map<列索引,列名>
*/
private Map<Integer, String> readColumnNode(NodeList columnNodes)
{
Map<Integer, String> columnMap = new HashMap<Integer, String>();
for (int k = 0; k < columnNodes.getLength(); k++)
{
Node columnNode = columnNodes.item(k);
if (columnNode.getNodeType() == 1)
{
String columnName =
columnNode.getAttributes().getNamedItem("name")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
String index =
columnNode.getAttributes().getNamedItem("index")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
columnMap.put(Integer.parseInt(index), columnName);
}
}
return columnMap;
}
/**
* 解析EXCEL文件配置文件
*
* @return Map<EXCEL文件名称,Map<Sheet页名称, Map<数据库表字段,对应Sheet页中的列名>>>
*/
public Map<String, Map<String, Map<String, String[]>>> readConfigXMLFile()
{
String filePath =Constant.PROJECT_DIR+ Constant.CONFIG_FILE_PATH;
DocumentBuilder builder;
Document doc;
Map<String, Map<String, Map<String, String[]>>> fileMap =
new HashMap<String, Map<String, Map<String, String[]>>>();
try
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
log.info("Load file [" + filePath + "]");
doc = builder.parse(new File(filePath));
Element root = doc.getDocumentElement();
NodeList nodeList = root.getElementsByTagName("excelfile");
for (int i = 0; i < nodeList.getLength(); i++)
{
Node excelfileNode = nodeList.item(i);
if (excelfileNode.getNodeType() == 1)
{
String excelfileName =
excelfileNode.getAttributes().getNamedItem("filename")
.getNodeValue().trim()
.toLowerCase(Locale.getDefault());
String isExport= excelfileNode.getAttributes().getNamedItem("supportExport")
.getNodeValue().trim();
String language= excelfileNode.getAttributes().getNamedItem("language")
.getNodeValue().trim();
//保存支持导出文件名称
if (Boolean.valueOf(isExport))
{
exportFileNameList.add(excelfileName);
}
fileLanguageVersion.put(excelfileName, language);
NodeList sheetNodes = excelfileNode.getChildNodes();
fileMap.put(excelfileName,
readSheetNode(excelfileName, sheetNodes));
}
}
}
catch (Exception e)
{
log.error(e.getMessage(), e);
}
return fileMap;
}
/**
* 读取数据库配置表信息
*
* @return Map<表名,Map<列索引,列名>>
*/
public Map<String, Map<Integer, String>> readDatabaseXMLFile()
{
String filePath = Constant.PROJECT_DIR+Constant.DATABASE_FILE_PATH;
DocumentBuilder builder;
Document doc;
Map<String, Map<Integer, String>> fileMap =
new HashMap<String, Map<Integer, String>>();
try
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
log.info("Load file [" + filePath + "]");
doc = builder.parse(new File(filePath));
Element root = doc.getDocumentElement();
NodeList nodeList = root.getElementsByTagName("table");
for (int i = 0; i < nodeList.getLength(); i++)
{
Node excelfileNode = nodeList.item(i);
if (excelfileNode.getNodeType() == 1)
{
String tableName =
excelfileNode.getAttributes().getNamedItem("name")
.getNodeValue().trim()
.toLowerCase(Locale.getDefault());
NodeList columnNodes = excelfileNode.getChildNodes();
fileMap.put(tableName, readColumnNode(columnNodes));
}
}
}
catch (Exception e)
{
log.error(e.getMessage(), e);
}
return fileMap;
}
/**
* 解析文件节点下的所有Sheet页配置
*
* @param columnNodes Sheet页节点List
* @return Map<Sheet页名称, Map<数据库表字段,对应Sheet页中的列名>>
*/
private Map<String, Map<String, String[]>> readSheetNode(
String excelfileName, NodeList sheetNodes)
{
Map<String, Map<String, String[]>> sheetMap =
new HashMap<String, Map<String, String[]>>();
Map<String, String> sheetNameMap = new HashMap<String, String>();
List<String> list = new ArrayList<String>();
for (int k = 0; k < sheetNodes.getLength(); k++)
{
Node sheetNode = sheetNodes.item(k);
if (sheetNode.getNodeType() == 1)
{
String tableName =
sheetNode.getAttributes().getNamedItem("tableName")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
String sheetName =
sheetNode.getAttributes().getNamedItem("sheetname")
.getNodeValue().trim().toLowerCase(Locale.getDefault());
sheetNameMap.put(sheetName, tableName);
NodeList columnNodes = sheetNode.getChildNodes();
Map<String, String[]> columnMap = readcolumnNode(columnNodes);
sheetMap.put(sheetName, columnMap);
if (tableMap.containsKey(tableName))
{
tableName = tableName + "_" + sheetName;
}
tableMap.put(tableName, columnMap);
list.add(sheetName);
}
}
fileNameMap.put(excelfileName, sheetNameMap);
fileSheetNameMap.put(excelfileName, list);
return sheetMap;
}
=========================================================================================================================
加密与解密
public class CipherUtil
{
private static OMSLog log = Tools.getLog(CipherUtil.class);
private static String CIPHER_TYPE = "AES";
private static String CIPHER_MODE = "AES/ECB/PKCS5Padding";
/**
* 用AES算法解密
*/
public static String decryptPwd(String input)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IOException, IllegalBlockSizeException,
BadPaddingException
{
return decryptPwd(input,false);
}
/**
* 服务端用AES算法解密
*/
public static String decryptPwd(String input,boolean isServer)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IOException, IllegalBlockSizeException,
BadPaddingException
{
byte[] keydata = isServer?getKey(Constant.CipherKey_SERVER_FILE_PATH):getKey();
SecretKeySpec key = new SecretKeySpec(keydata, 0, 16, CIPHER_TYPE);
Cipher cipher = Cipher.getInstance(CIPHER_MODE);
cipher.init(Cipher.DECRYPT_MODE, key);
BASE64Decoder decoder = new BASE64Decoder();
byte[] data = decoder.decodeBuffer(input);
byte[] decryptData = cipher.doFinal(data, 0, data.length);
return new String(decryptData);
}
/**
* 用AES算法加密
*
* @throws IOException
*/
public static String encryptPwd(String input)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException,
IOException
{
SecretKeySpec key = new SecretKeySpec(getKey(), 0, 16, CIPHER_TYPE);
Cipher cipher = Cipher.getInstance(CIPHER_MODE);
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] bs = cipher.doFinal(input.getBytes());
return new sun.misc.BASE64Encoder().encode(bs);
}
/**
* 生成AES加密密钥
*
* @throws IOException
* @throws NoSuchPaddingException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws BadPaddingException
* @throws IllegalBlockSizeException
*/
private static byte[] getKey()
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException,
IOException
{
return getKey(Constant.CipherKey_FILE_PATH);
}
/**
* 生成AES加密密钥
*
* @throws IOException
* @throws NoSuchPaddingException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws BadPaddingException
* @throws IllegalBlockSizeException
*/
private static byte[] getKey(String path)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException,
IOException
{
String initKey = "ci~+Ides5ign*1=)";
String input =
Tools.getStringNoNull(Tools.getPropertiesByFile(
path).getProperty("CipherKey"));
SecretKeySpec key = new SecretKeySpec(initKey.getBytes(), CIPHER_TYPE);
Cipher cipher = Cipher.getInstance(CIPHER_MODE);
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] bs = cipher.doFinal(input.getBytes());
return bs;
}
=========================
http://www.iteye.com/topic/1122076
发表评论
-
java 中的文件读取信息
2013-03-11 08:56 1058import java.io.BufferedReader ... -
oracle结果集的操作信息
2013-03-04 16:22 914众所周知的几个结果集集合操作命令,今天详细地测试了一下,发现一 ... -
js正则表达式(二)
2013-01-09 11:20 885首先加个重要的东西 * ... -
java路径问题以及java对文件的基本操作信息
2012-12-19 14:09 9751.基本概念的理解 绝对 ... -
JS正则表达式
2012-11-15 17:10 851function isTrueName(s) { var pa ... -
java公用类
2012-11-15 17:05 864package cn.org.jshuwei.j2ee.uti ... -
java规范信息
2012-10-30 08:44 27881 一、判断选择题(每题1分) 1. 表达式要在低优先级操作符 ... -
java时间公用和StringUnitl以及java调用存储过程
2012-10-16 17:38 16151 构建存储过程的语句信息 /** * 从Fun ... -
jquery批量删除
2012-09-20 14:31 3389<%@ page language="java ... -
java操作execl文件(2003与2007不兼容问题)
2012-09-19 14:49 1476package com.huawei.bss.execlCom ... -
java操作execl文件
2012-09-19 08:53 986package com.huawei.bss.execlCom ... -
通过onkeypress和onkeydown事件禁用键盘中某些键
2012-09-17 15:09 953http://zywang.iteye.com/blog/70 ... -
properties的修改
2012-09-14 16:05 1011public static void modifyProper ... -
STRUTS2与JSON的LIST和MAP对象返回
2012-09-07 14:57 6685<%@ page language="java ... -
struts2 iterator双重叠迭取值
2012-09-05 18:08 1259•效果:Map<String,List<Derpa ... -
struts2多个配置文件的应用
2012-09-05 10:10 1075<!-- 定义Struts2的核心Filter --&g ... -
java中使用net.sf.json对json进行解析
2012-09-04 12:24 1023作者: http://zhangnet1.iteye.com/ ... -
XML的TreeConfig
2012-09-04 10:20 912/** * <?xml version=&qu ... -
JSON与 STRuts2
2012-09-04 10:20 1310package com.huawei.cmclient.com ... -
sql在不同数据库查询前几条数据
2012-09-03 15:14 800sql在不同数据库查询前几条数据 1. ORACLE ...
相关推荐
关于java多线程的一点个人学习记录,仅供同在学习多线程的伙伴参考。
通常,在大学里用Java讲授Java时,会使用IDE,但是当您真正想学习一些东西时,则不应使用使您轻松学习的工具,至少在学习时不这样做。 此练习和下一个练习的另一个重要方面是docker的功能。 Docker具有一些出色的...
java8 源码 Java Java基础 Java高新技术 [泛型--GenericType] [反射--Reflect] [枚举--Enum] [Java8--时间API] [Java8--StreamAPI] Java多线程 Java并发 [Java并发之线程池(二)之Executors] Java设计模式 Android UI...
Titandb 学习主站 呆萌狮 - Demo's 公司维护: 四方环视 如果你也搭建好了,欢迎通过 Pull Request 将你的站点加到这个列表中 :-p 功能特性 具体功能点细节可浏览 Sym 功能点脑图,下面列出了 Sym 的主要...
JavaThings-Java安全漫谈笔记相关《 Java安全漫谈》是我在写的一点Java学习相关的随笔,不是很严谨,也不是啥高科技。这个存储库主要是记录并整理一下,附加一些代码。Java安全漫谈目录 人口统计字节码:远程字节码...
既然不能做到过目不忘,索性把看到的记下来,做笔记的好处就是下次碰到问题时直接查看经过自己总结的笔记有事半功倍的效果,因此也养成了学习一点就记一点的习惯。以前喜欢用Evernote来记录,现在用GitHub。 ####...
笔记大都基于视频教程的学习记录,有的地方是对视频里老师原话的复述,有的地方加上了自己的一点理解,有的内容来源于对网上博文干货的整理。若存在错误,还请各位大侠指出哈。 另外,目前只学了 Java 基础、JavaWeb...
总结我这几年的一点经验:安全需要学习的技术太多了,特别是红队、渗透测试、如果是安服相对来说不是那么多,但是我们精力有限,根本不可能学完。至于如何学?我们可以把学习当做是玩游戏一样,看你怎么点你的技能点...
项目结束以后,主要在复习Java基础,于是看了不少相关博客,记录了很多Java的基础知识点,比如异常,反射,序列化,集合类等等内容的一些总结,现在看来确实有点幼稚了。所以我最近也在删除一些低质量的文章,以便让...
《Java学习+面试指南》 历程 2-28日:每个人都在努力都在奋不顾身,不是只有你受尽委屈 计划一星期复习java基础 看完了《核心技术卷一》的一到四章,记录见: 看了下B站上的左程云的算法课——排序 找到了几个算法...
丝,有幸能够在大规模分布式系统下工作,故在此记录一些浅薄认识,作为自己未来学习路线的参考。 一、分布式系统概述 分布式系统往往是把应用拆分成多个应用,每个团队维护一个应用,应用与应用通过远程...
基于这一点,朋友学习java需要花费更多的时间和精力,去理解编程中存在的深度与广度。 一些在我看来很简单的问题,朋友可能会觉得匪夷所思。 为了磨平双方存在的分歧,抵消在空间上和时间上的不一致,我建立了这个...
java小超市管理系统源码简历:大卫·桑德斯 开发者简介 我是一名喜欢与开源合作并回馈开源社区的开发人员。 你可能会发现我在 freenode 上闲逛#django,回答有关 Django 的问题。 我主要使用 Python/Django/Postgres...
本周五,接到一个任务,要使用爬虫技术来获取某点评网站里面关于健身场馆的数据,之前从未接触过爬虫技术,于是就从网上搜了一点学习资料,本篇文章就记录爬虫技术Jsoup技术,爬虫技术听名称很牛叉,其实没什么难点...
简单化一点, 我们可以用 eregi()取代 ereg().eregi()对大小写不敏感, 我们就不需要指定两个范围 "a-z" 和 "A-Z" – 只需要指定一个就可以了: ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ 后面的服务器名字也是一样,但要去掉...
java8集合源码边干边学 Mackenzie Child 的视频给了我很大的启发。 所以我决定按照他所有的 rails 视频教程来学习如何构建一个 Web 应用程序。 通过视频,我会尝试自己构建Web应用程序,并将课程逐步记录在文本中,...
在学习中很多学生认为这门课程既 难学、又看不到任何成果, 不如 Java 等语言很快就能编写出有漂亮图形界面的程序。 但C 语言有助于对计算机编程底层原理的理解,对调整知识结构和能力结构,提高自己的综 合素质都有...
java shuffle源码 前言 之前没怎么在GitHub MD中写过目录索引,下文目录中有的锚点不能跳转(尤其是IE内核的浏览器),我也没办法。这里我将下文放到了我CSDN的博客上,可以跳转目录,看起来也方便美观一点—— 这里...
汉诺塔java源码网络开发和计算机科学基础 概要 我创建了这个 git 存储库来记录我在 Web 开发方面的技能和知识的发展,并在相关的计算机科学学科中建立了强大的基础 动机 互联网最伟大的事情是信息的民主化。 与历史...
一、为什么要学注解? 在日常开发中,基本都是在使用别人定义或是各种...所以如果你想走上人生巅峰,更好的利用框架,又或者想要高一点的逼格,从团队中突出,那么学习注解都是前提。 二、注解是什么? 在Java中