Discuss / Java / 练习:复制文件内容

练习:复制文件内容

Topic source

jasmine

#1 Created at ... [Delete] [Delete and Lock User]

// 复制文件内容

static void copy(String source, String target) throws IOException {

    try (InputStream input = new FileInputStream(source);

         OutputStream output = new FileOutputStream(target))

    {

        input.transferTo(output); // transferTo的作用是复制

    }

}


  • 1

Reply