文件名称:Java:二进制方式读取文件
文件大小:33KB
文件格式:DOC
更新时间:2015-11-06 14:21:09
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循环保证只写入count个byte, 否则会写入1024个byte
for(i=0; i