import java.io.*; public class CopyFile { public static void main(String[] args) throws Exception { String source = "src/test.java"; String target = "out/test.java"; copy(source, target); } static void copy(String source, String target) throws IOException { byte[] buffer = new byte[1024 * 8]; try (InputStream input = new FileInputStream(source); OutputStream output = new FileOutputStream(target)) { int length; while ((length = input.read(buffer)) != -1) { output.write(buffer, 0, length); } } } }
Sign in to make a reply
韦雪松