• Java-IO:复制文件


     1 import java.io.FileInputStream;
     2 import java.io.FileNotFoundException;
     3 import java.io.FileOutputStream;
     4 import java.io.IOException;
     5 
     6 public class CopyFileDemo {
     7     public static void main(String[] args) {
     8 
     9         FileInputStream fis = null;
    10         FileOutputStream fos = null;
    11         try {
    12             fis = new FileInputStream("js.mp3");
    13             fos = new FileOutputStream("copy_js.mp3");
    14             // BufferedInputStream bis=new BufferedInputStream(fis);
    15             // BufferedOutputStream bos=new BufferedOutputStream(fos);
    16             byte[] bt = new byte[1024];
    17             int len = 0;
    18             while ((len = fis.read(bt)) != -1) {
    19                 fos.write(bt, 0, len);
    20             }
    21         } catch (FileNotFoundException e) {
    22             e.printStackTrace();
    23         } catch (IOException e) {
    24             e.printStackTrace();
    25         } finally {
    26             try {
    27                 if (fis != null)
    28                     fis.close();
    29                 if (fos != null)
    30                     fos.close();
    31             } catch (IOException e) {
    32                 e.printStackTrace();
    33             }
    34         }
    35     }
    36 }
  • 相关阅读:
    mac前端解除端口占用命令
    Mac安装Brew
    Mac Webstrom 快捷键
    linux yarn安装
    js-新兴的API,最佳实践,离线应用于客户端存储
    js-高级技术
    js-Ajax与Comet
    js-错误处理与调试,JSON
    js-DOM2,表单脚本
    js-事件
  • 原文地址:https://www.cnblogs.com/jsersudo/p/10097366.html
Copyright © 2020-2023  润新知