????java?????????????
???????????Reader/Writer ???????InputStream/OutputStream
?????????????????????????????????????????????????????????????????????????????????????????????
???????java.io.File?е????
????public static void copyByFileStreams(File source?? File dest){
????FileInputStream inputStream = null;
????FileOutputStream outputStream = null;
????try{
????inputStream = new FileInputStream(source);
????outputStream = new FileOutputStream(dest);
????//??????????棬???????д??
????//byte[] b = new byte[(int)source.length()];
????//inputStream.read(b);
????//outputStream.write(b);
????//?????д
????int len = 0;
????while((len = inputStream.read(b)) != -1){
????outputStream.write(len);
????}
????}catch (IOException e) {
????e.printStackTrace();
????} finally {
????try {
????if (inputStream != null) {
????inputStream.close();
????}
????if (outputStream != null) {
????outputStream.close();
????}
????} catch (IOException e) {
????e.printStackTrace();
????}
????}
????}
???????java.nio.Channels?е????
????public static void copyByFileChannels(File source?? File dest) {
????FileInputStream inputStream = null;
????FileOutputStream outputStream = null;
????try {
????inputStream = new FileInputStream(source);
????outputStream = new FileOutputStream(dest);
????FileChannel inputChannel = inputStream.getChannel();
????FileChannel outputChannel = outputStream.getChannel();
????outputChannel.transferFrom(inputChannel?? 0?? inputChannel.size());
????} catch (IOException e) {
????e.printStackTrace();
????} finally {
????try {
????if (inputStream != null) {
????inputStream.close();
????}
????if (outputStream != null) {
????outputStream.close();
????}
????} catch (IOException e) {
????e.printStackTrace();
????}
????}
????}
???????Java7??Files.copy??????
????/**
????* ???java7??Files.copy???????????????????????FileChannels
????* @param source
????* @param dest
????*/
????public static void copyByJava7Files(File source?? File dest) {
????try {
????Files.copy(source.toPath()??dest.toPath());
????} catch (IOException e) {
????e.printStackTrace();
????}
????}
???????????????????????????????????FileChannelЧ????????????????????????????ü??????????????????ɡ?^_^