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


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


          網站導航:
           

          My Links

          Blog Stats

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 海南省| 凤山县| 潼南县| 芦溪县| 靖宇县| 临高县| 北辰区| 固阳县| 四会市| 灵山县| 陆良县| 安塞县| 五原县| 海盐县| 章丘市| 大冶市| 张家港市| 余姚市| 通河县| 普兰店市| 多伦县| 中宁县| 百色市| 长汀县| 德令哈市| 古浪县| 永新县| 广灵县| 老河口市| 绍兴市| 邻水| 石林| 瓦房店市| 南昌市| 长宁县| 万山特区| 板桥市| 富川| 吉木萨尔县| 雅安市| 江安县|