Created
July 28, 2012 00:55
-
-
Save MaySnow/3191292 to your computer and use it in GitHub Desktop.
file copy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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