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 閱讀(191) 評論(0)  編輯  收藏


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


          網站導航:
           

          My Links

          Blog Stats

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 娱乐| 通城县| 泰安市| 吴堡县| 成安县| 牙克石市| 阿克陶县| 临桂县| 五台县| 石狮市| 亚东县| 牙克石市| 上高县| 大新县| 略阳县| 无为县| 蒙阴县| 邵阳县| 虞城县| 洞口县| 麻城市| 永新县| 莆田市| 托克逊县| 永年县| 中超| 九寨沟县| 玛曲县| 连城县| 玛纳斯县| 襄樊市| 灯塔市| 华坪县| 密山市| 县级市| 左云县| 绍兴市| 常德市| 肥城市| 济宁市| 明水县|