/**加密
*
*/
public static String doEncrypt(String xmlStr) {
try {
return URLEncoder.encode(xmlStr, "GBK");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "加密错误";
}
/**
* 解密
* @param saveFile
*/
public static void decrypt(File saveFile) {
try {
BufferedReader reader = null;
reader = new BufferedReader(new FileReader(saveFile));
String tempString = null;
String str2 =null;
while ((tempString = reader.readLine()) != null) {
str2=URLDecoder.decode(tempString);
}
FileOutputStream fos = new FileOutputStream(saveFile);
fos.write(str2.getBytes());
fos.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws UnsupportedEncodingException {
System.out.println(URLDecoder.decode("C:\\Documents and Settings\\chenchangqing\\Desktop\\实物转移_20110824030821.xml", "GBK"));
}
这是把文件内容转换成字符的方式
摘要: 前台:
<form action="uploadimage.jsp" method="post" enctype="multipart/form-data" name="form1">
<input type="file" name="file">
<input type="submit"&n...
阅读全文