public class CopyFile {
public static void main(String[] args) throws IOException {
copy("F:\\testDemo.txt", "F:\\testDemo3.txt");
}
static void copy(String source, String target) throws IOException {
byte[] b=new byte[2000];
try(InputStream inputStream =new FileInputStream(source)){
try(OutputStream outputStream=new FileOutputStream(target)){
if ( (inputStream.read(b))!=-1) {
outputStream.write(b);
Sign in to make a reply
王能能Lily
public class CopyFile {
public static void main(String[] args) throws IOException {
copy("F:\\testDemo.txt", "F:\\testDemo3.txt");
}
static void copy(String source, String target) throws IOException {
byte[] b=new byte[2000];
try(InputStream inputStream =new FileInputStream(source)){
try(OutputStream outputStream=new FileOutputStream(target)){
if ( (inputStream.read(b))!=-1) {
outputStream.write(b);
}
}
}
}
}