String fileName = "test.zip";
String savePath = "tedd.zip";
try
{
DataInputStream dis = new DataInputStream(
new FileInputStream(fileName));
DataOutputStream dos = new DataOutputStream(
new FileOutputStream(savePath));
int bufferSize = 1024;
byte[] buf = new byte[bufferSize];
while (true) {
int read = 0;
if (dis != null) {
read = dis.read(buf, 0, bufferSize);
}
if (read == -1) {
break;
}
dos.write(buf, 0, dis.read(buf));
dos.flush();
}
dos.close();
dis.close();
}
catch (IOException e)
{
e.printStackTrace();
}
dos.write(buf, 0, dis.read(buf)); 改成dos.write(buf, 0, read);