chenjinlong

          文件加密解密

          /**加密
            *
            */
           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 on 2011-08-26 11:49 chenjinlong 閱讀(190) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          My Links

          Blog Stats

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 古浪县| 西城区| 霍林郭勒市| 普格县| 芷江| 克拉玛依市| 五河县| 修水县| 湘西| 镶黄旗| 梁山县| 甘南县| 南华县| 安化县| 纳雍县| 察雅县| 融水| 枣强县| 保定市| 定兴县| 克什克腾旗| 华安县| 应用必备| 长阳| 德阳市| 冀州市| 伊吾县| 沁阳市| 瓦房店市| 昂仁县| 灵寿县| 普宁市| 孙吴县| 新乡市| 海淀区| 彩票| 新平| 徐州市| 庆云县| 远安县| 浏阳市|