package com.oracle.huanchongliu;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import org.junit.Test;
public class Test_huanchong {
/**
* 实用了文件流和缓冲流
*/
@Test
public void test1(){
File file=new File("E:\\冰与火之歌\\[电影天堂www.dy2018.net]冰与火之歌:权力的游戏第一季05集中英双字[1024分辨率].RMVB");
File file1=new File("E:\\复制1.RMVB");
long t1=System.currentTimeMillis();
long t2=0;
FileInputStream fis=null;
FileOutputStream fos=null;
BufferedInputStream bis=null;
BufferedOutputStream bos=null;
try {
fis=new FileInputStream(file);
bis=new BufferedInputStream(fis);
fos=new FileOutputStream(file1);
bos=new BufferedOutputStream(fos);
byte[] by=new byte[1024];
int len=1024;
while((len=bis.read(by))!=-1){
bos.write(by, 0, len);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t2=System.currentTimeMillis();
System.out.println(t2-t1);
}
/**
* 什么也不使用的,只用了文件流
*/
@Test
public void test2(){
File file=new File("E:\\冰与火之歌\\[电影天堂www.dy2018.net]冰与火之歌:权力的游戏第一季05集中英双字[1024分辨率].RMVB");
File file1=new File("E:\\复制2.RMVB");
long t1=System.currentTimeMillis();
long t2=0;
FileInputStream fis=null;
FileOutputStream fos=null;
try {
fis=new FileInputStream(file);
fos=new FileOutputStream(file1);
byte[] by=new byte[1024];
int len=1024;
while((len=fis.read(by))!=-1){
fos.write(by, 0, len);
fos.flush();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t2=System.currentTimeMillis();
System.out.println(t2-t1);
}
/**
* 使用了文件流、缓冲流、转换流
*/
@Test
public void test3(){
File file=new File("E:\\冰与火之歌\\[电影天堂www.dy2018.net]冰与火之歌:权力的游戏第一季05集中英双字[1024分辨率].RMVB");
File file1=new File("E:\\复制3.RMVB");
long t1=System.currentTimeMillis();
long t2=0;
FileInputStream fis=null;
InputStreamReader isr=null;
BufferedReader bis=null;
FileOutputStream fos=null;
OutputStreamWriter osw=null;
BufferedWriter bos=null;
try {
fis=new FileInputStream(file);
isr=new InputStreamReader(fis);
bis=new BufferedReader(isr);
fos=new FileOutputStream(file1);
osw=new OutputStreamWriter(fos);
bos=new BufferedWriter(osw);
char[] by=new char[1024];
int len=1024;
while((len=bis.read(by))!=-1){
bos.write(by,0,len);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t2=System.currentTimeMillis();
System.out.println(t2-t1);
}
}
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import org.junit.Test;
public class Test_huanchong {
/**
* 实用了文件流和缓冲流
*/
@Test
public void test1(){
File file=new File("E:\\冰与火之歌\\[电影天堂www.dy2018.net]冰与火之歌:权力的游戏第一季05集中英双字[1024分辨率].RMVB");
File file1=new File("E:\\复制1.RMVB");
long t1=System.currentTimeMillis();
long t2=0;
FileInputStream fis=null;
FileOutputStream fos=null;
BufferedInputStream bis=null;
BufferedOutputStream bos=null;
try {
fis=new FileInputStream(file);
bis=new BufferedInputStream(fis);
fos=new FileOutputStream(file1);
bos=new BufferedOutputStream(fos);
byte[] by=new byte[1024];
int len=1024;
while((len=bis.read(by))!=-1){
bos.write(by, 0, len);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t2=System.currentTimeMillis();
System.out.println(t2-t1);
}
/**
* 什么也不使用的,只用了文件流
*/
@Test
public void test2(){
File file=new File("E:\\冰与火之歌\\[电影天堂www.dy2018.net]冰与火之歌:权力的游戏第一季05集中英双字[1024分辨率].RMVB");
File file1=new File("E:\\复制2.RMVB");
long t1=System.currentTimeMillis();
long t2=0;
FileInputStream fis=null;
FileOutputStream fos=null;
try {
fis=new FileInputStream(file);
fos=new FileOutputStream(file1);
byte[] by=new byte[1024];
int len=1024;
while((len=fis.read(by))!=-1){
fos.write(by, 0, len);
fos.flush();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t2=System.currentTimeMillis();
System.out.println(t2-t1);
}
/**
* 使用了文件流、缓冲流、转换流
*/
@Test
public void test3(){
File file=new File("E:\\冰与火之歌\\[电影天堂www.dy2018.net]冰与火之歌:权力的游戏第一季05集中英双字[1024分辨率].RMVB");
File file1=new File("E:\\复制3.RMVB");
long t1=System.currentTimeMillis();
long t2=0;
FileInputStream fis=null;
InputStreamReader isr=null;
BufferedReader bis=null;
FileOutputStream fos=null;
OutputStreamWriter osw=null;
BufferedWriter bos=null;
try {
fis=new FileInputStream(file);
isr=new InputStreamReader(fis);
bis=new BufferedReader(isr);
fos=new FileOutputStream(file1);
osw=new OutputStreamWriter(fos);
bos=new BufferedWriter(osw);
char[] by=new char[1024];
int len=1024;
while((len=bis.read(by))!=-1){
bos.write(by,0,len);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t2=System.currentTimeMillis();
System.out.println(t2-t1);
}
}