怎么把文件写成“不可读”文件就是用记事本打开时看到HB
0QR#W螛nlb 0
 
 \O€3?g
 
 w w w . Q i s u u . c o m tet6R\O v^衏汷 N}? 
 
 
 ,{ N鄗 0倫惙儩[w峹y飠
 
  0
 
 塻钑sQY 絻絻臑檒 imp鄀燱  NGr^XYR兩Qofa?0
 
  N篘塻钑sQ匭  N蝪6q%fa耣b?€eg I價俁桼?眰齸觿~?銷篘^yn顅=r _? `'YEu0
 
 sQ匭剉u蒕銼S?N  N篘V{l氺rL?q櫲?N鄀P?fa 拺6q2k墤 鉙-N
N亂T鶴U鉔'Y讒篘媠KN剉CS銼輣錝 臑砽軓
N陙慛魰  NGrd[蜽N蚇q\0?{UO{?`lb骻 %f螛
N塻钑sQ0 胈-NahaNu 鍌^棽N珟*j!n'Y o q欁S臑檒聄螛KN鎮 /f坃緰R瀃SOsT0R購CS銼輣1U剉髞駇匭祄剉0dk篘縊/f N鉔QRj屛?nlb0
 N

解决方案 »

  1.   

    写入的时候加密就是了。//类Cmdpublic class Cmd {
    public static void main(String[] args) {
    try { JBBMailAngokaCmd cmd = new JBBMailAngokaCmd();
    cmd.execute("F:\\aa.txt", "\\bb.txt");
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    public void execute(String inFilename, String outFilename)
    throws Exception {
    InputStream is = new FileInputStream(inFilename);
    OutputStream os = new FileOutputStream(outFilename);
    String line = "";
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(os));
    line = reader.readLine();
    while (line != null) {
    line = Decryption.encrypt(String.valueOf(line));
    writer.println(line);
    line = reader.readLine();
    }
    writer.flush();
    is.close();
    os.close();
    }
    }//类Decryption
    public class Decryption {    private static final String PASSWORD = "YAKINIKU3000";    private static final String ALGORITHM = "DES";    public final static String encrypt(String data) throws Exception  {
            return byte2hex(encrypt(data.getBytes(), PASSWORD
                    .getBytes()));
        }
        private static byte[] encrypt(byte[] data, byte[] key) throws Exception {        SecureRandom sr = new SecureRandom();
            DESKeySpec dks = new DESKeySpec(key);
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
            SecretKey securekey = keyFactory.generateSecret(dks);
            Cipher cipher = Cipher.getInstance(ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, securekey, sr);
            byte[] cipherData =cipher.doFinal(data);
            return cipherData;
        }
        public static String byte2hex(byte[] b) {
            String hs = "";
            String stmp = "";
            for (int n = 0; n < b.length; n++) {
                stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
                if (stmp.length() == 1) {
                    hs = hs + "0" + stmp;
                } else {
                 hs = hs + stmp;
                }
            }
            return hs.toUpperCase();
        }
    }