import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileEnc {
public static void main(String[] args) throws Exception {
System.out.println(-1 - 10);
System.out.println(-(-11 + 1));
String path = "D:\\1tmp\\enc" + File.separator + "scdec.zip";
String encPath = "D:\\1tmp\\enc" + File.separator + "encsc.zip";
File rfile = new File(path);
System.out.println(rfile.isFile());
System.out.println(rfile.exists());
File eFile = new File(encPath);
FileInputStream fis = new FileInputStream(eFile);
FileOutputStream fos = new FileOutputStream(rfile);
transFoToFileDec(fis, fos);
}
public static void transFoToFileDec(FileInputStream fis, FileOutputStream fos) {
try {
byte[] b = new byte[1024 * 10];
int len = 0;
while ((len = fis.read(b)) != -1) {
for (int j = 0; j < len; j++) {
b[j] = (byte) (-((int) b[j] + 1));
}
fos.write(b, 0, len);
}
} catch (Exception e) {
System.out.println(e);
throw new RuntimeException("文件复制失败");
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
System.out.println(e);
throw new RuntimeException("文件复制失败");
}
}
}
}
}
}
public static void transFoToFileEnc(FileInputStream fis, FileOutputStream fos) {
try {
byte[] b = new byte[1024 * 10];
int len = 0;
while ((len = fis.read(b)) != -1) {
for (int j = 0; j < len; j++) {
b[j] = (byte) (-1 - (int) b[j]);
}
fos.write(b, 0, len);
}
} catch (Exception e) {
System.out.println(e);
throw new RuntimeException("文件复制失败");
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
System.out.println(e);
throw new RuntimeException("文件复制失败");
}
}
}
}
}
}
}