本教程介绍了如何使用Java编程语言以二进制格式高效地读取文件内容的方法和技巧。
以下是经过调整的代码示例:
```java
package hustspy.encrypt;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileOperation {
public static void main(String[] args) {
String src = 111.txt;
String dec = 222.txt;
try {
FileInputStream in = new FileInputStream(src);
// 以下两行代码用于创建目标文件,如果已经存在则不需要执行
// File file = new File(dec);
// if (!file.exists()) file.createNewFile();
FileOutputStream out = new FileOutputStream(dec);
byte buffer[] = new byte[1024];
int count, i;
while ((count=in.read(buffer)) != -1) {
for (i=0; i