/**
* 加密解密
* @param filePath 文件路径
* @param code 加密解密码
* @throws IOException
* @return 加密后文件生成路径
*/
public static String enOrDecryption(String filePath,int code) throws IOException {
if(filePath==null||filePath.trim().equals("")){
return "";
}
File oldFile=new File(filePath);
//原文件输入流
FileInputStream fis=new FileInputStream(oldFile);
//加密后文件输出流
File newFile=new File(oldFile.getParent(),"m"+oldFile.getName());
FileOutputStream fos=new FileOutputStream(newFile);
while (true){
int i=fis.read();
if(i==-1) break;
//异或操作:X^A^A=X^(A^A)=X^0=X
fos.write(i^code);
}
fis.close();
fos.close();
return newFile.getAbsolutePath();
}