import java.io.*;
import java.lang.Math.*;
public class RandomAccessFile{
public static void main(String argv[]){
File file1;
RandomAccessFile fp;
byte[] buf;
int i;
if(argv.length<1){
System.out.println("需要指定待加密文件名称");
return ;
}
try{
file1=new File(argv[0]);
fp=new RandomAccessFile(file1,"rw");
buf=new byte[(int)file1.length()];
fp.read(buf);
for(i=0;i<buf.length;i++)
buf[i]=byte(~buf[i]);
fp.seek(0);
fp.write(buf);
p.close();
System.out.println("加密成功");
}
catch(IOException e){
System.out.println("文件读写失败");
}
}
}
报错如图