我尝试通过 java 编写代码,能够从文件中读取 100 kb,然后将文件分成块,每个块有 256 位或 32 字节,我还想将每个块转换为二进制格式或整数格式,以下是我需要的任何建议
public static void main(String[] args) {
ReadFileExample newclass = new ReadFileExample();
System.out.println("-----------Wellcome in ECC ENCRYPTION NEW--------");
File clearmsg = new File("F:/java_projects/clearmsg.txt");
File ciphermsg = new File("F:/java_projects/ciphermsg.txt");
byte[] block = new byte[32];
try {
FileInputStream fis = new FileInputStream(clearmsg);
FileOutputStream fos = new FileOutputStream(ciphermsg);
CipherOutputStream cos = new CipherOutputStream(fos);
System.out.println("Total file size to read (in bytes) : "
+ fis.available());
int i;
while ((i = fis.read(block)) != -1) {
System.out.println(block);
fos.write(block, 0, i);
}
fos.close();