日期:2014-05-20 浏览次数:20926 次
public static void main(String[] args) throws IOException {
// 把文件流写入到容器中
ArrayList ls = new ArrayList();
FileInputStream fins = new FileInputStream("d:/soft/chrome_installer.exe");
byte[] ifdata = new byte[1024];
int iflen=0;
while ((iflen = fins.read(ifdata)) > -1) {
ls.add(reset(ifdata, iflen));
}
fins.close();
// 从容器中取出文件
FileOutputStream fouts = new FileOutputStream("c:/1.exe");
for (int i = 0; i < ls.size(); i++) {
fouts.write((byte[]) ls.get(i));
}
fouts.flush();
fouts.close();
}
public static byte[] reset(byte[] in, int len) {
byte[] b = new byte[len];
System.arraycopy(in, 0, b, 0, len);
return b;
}