Skip to content

Instantly share code, notes, and snippets.

@MaySnow
Created July 28, 2012 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaySnow/3191292 to your computer and use it in GitHub Desktop.
Save MaySnow/3191292 to your computer and use it in GitHub Desktop.
file copy
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyFile {
public static void main(String[] args) throws IOException {
FileInputStream inStream = new FileInputStream("c:/白.jpg");
FileOutputStream outStream = new FileOutputStream("c:/白2.jpg");
byte[] buffer = new byte[512];
int len = -1;
while((len = inStream.read(buffer)) != -1) {//一定要传入buffer
outStream.write(buffer, 0, len);
}
inStream.close();
outStream.flush();
outStream.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment