chenjinlong

2010年11月12日 #

文件加密解密

/**加密
  *
  */
 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"));
 }




这是把文件内容转换成字符的方式

posted @ 2011-08-26 11:49 chenjinlong 阅读(175) | 评论 (0)编辑 收藏

smartupload.jar 实现文件上传下载

     摘要: 前台: <form action="uploadimage.jsp" method="post" enctype="multipart/form-data" name="form1"> <input type="file" name="file"> <input type="submit"&n...  阅读全文

posted @ 2010-11-12 20:44 chenjinlong 阅读(1856) | 评论 (0)编辑 收藏

My Links

Blog Stats

常用链接

留言簿

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜