- /**
- * 拷贝单个文件的代码
- * @author luo
- *
- */
- public class FileStramDome {
- public static void main(String[] s) {
- FileOutputStream fos = null;
- FileInputStream fis = null;
- try {
- fos = new FileOutputStream("bbb.bmp"); //原文件名和路径
- fis = new FileInputStream("D://aaa.bmp"); //拷贝的文件名
- byte[] bs = new byte[1024];
- int len = 0;
- while ((len = fis.read(bs)) != -1) {
- fos.write(bs, 0, len);
- }
- } catch (Exception e) {
- } finally {
- try {
- if (fos != null) {
- fos.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- if (fis != null) {
- fis.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
复制代码 |
|