喜欢研究学习技术,喜欢和志同道合的人交流。 从事测试6年,专职性能3年经验,擅长性能测试,测试框架开发。 励志格言:只要想学习,永远都不会太晚;只要想进步,永远都会有空间。

java vuser之 IO文件读写复制(二进制读写)

上一篇 / 下一篇  2018-06-20 10:45:05 / 个人分类:性能测试

import lrapi.lr;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;


public class Actions
{
     FileInputStream fis=null; //定义文件输入对象
     FileOutputStream fout=null; //定义文件输出对象
  

public int init() throws Throwable {
return 0;
}//end of init



public int action() throws Throwable {
    lr.start_transaction("readfile");
   
    fis=new FileInputStream("D:\\test.txt");
fout=new FileOutputStream("D:\\mudi.txt",true);
byte[] bt=new byte[1024];
int leng=fis.read(bt);
String str=new String(bt,0,leng);
while(leng==-1){
break;
}
//System.out.print(str);
fout.write(bt, 0, leng);
fout.flush();

lr.end_transaction("readfile", lr.AUTO);
return 0;
                

}//end of action



public int end() throws Throwable {
    try {
if(fis!=null){
    fis.close();
}
    } catch (Exception  e) {
e.printStackTrace();
    }


      try {
if(fout!=null){
    fout.close();
}
    } catch (Exception  e) {
e.printStackTrace();
    }
return 0;
}//end of end
}


TAG:

 

评分:0

我来说两句

Open Toolbar