package updateFile;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public class UpLoadFile {
public static void main(String[] args) {
File src = new File("d:/1.txt");
File target = new File ("d:/1/1.txt");
copy(src,target);
System.out.println("succeed");
}
private static void copy(File src, File target) {
try {
InputStream in = null;
OutputStream out = null;
try {
in = new BufferedInputStream(new FileInputStream(src), 1024);
out = new BufferedOutputStream(new FileOutputStream(target), 1024);
byte[] buffer = new byte[1024];
while (in.read(buffer) > 0) {
out.write(buffer);
}
} finally {
if (null != in) {
in.close();
}
if (null != out) {
out.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public class UpLoadFile {
public static void main(String[] args) {
File src = new File("d:/1.txt");
File target = new File ("d:/1/1.txt");
copy(src,target);
System.out.println("succeed");
}
private static void copy(File src, File target) {
try {
InputStream in = null;
OutputStream out = null;
try {
in = new BufferedInputStream(new FileInputStream(src), 1024);
out = new BufferedOutputStream(new FileOutputStream(target), 1024);
byte[] buffer = new byte[1024];
while (in.read(buffer) > 0) {
out.write(buffer);
}
} finally {
if (null != in) {
in.close();
}
if (null != out) {
out.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}