FileInputStream fis = new FileInputStream("D:\\java\\xuexi\\Java test\\image\\damie.jpg"); FileOutputStream fos = new FileOutputStream("aaaa.jpg"); byte[] buf = new byte[1024]; int len; while ((len=fis.read(buf)) !=-1){ fos.write(len^2); } fis.close(); fos.close();
用于文件加密
^:异或
两边相同用:false
两边不同:true
FileInputStream fis =new FileInputStream("aaaa.jpg"); FileOutputStream fos=new FileOutputStream("b.jpg"); int b; while ((b = fis.read()) != -1) { fos.write(b^2); } fis.close(); fos.close();