【文件属性】:
文件名称:关于文件复制的程序java
文件大小:925B
文件格式:JAVA
更新时间:2012-11-22 04:54:34
File_Stream
package math;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class OutputStream {
public static class CopyJDK {
public static void main(String[] args) {
String str = "D:/yf.jpg";
String strs = "D:/Output.jpg";
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(str);
fos = new FileOutputStream(strs);
byte[] buf = new byte[1024 * 1024];
int len;
while ((len = fis.read(buf)) != -1) {
fos.write(buf, 0, len);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fis.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("复制成功!");
}
}
}
}