如何在JMeter中将图像转换为流?

时间:2017-03-03 16:44:27

标签: image jmeter jpeg

我正在尝试使用BeanShell预处理将jpg图像转换为JMeter中的流。下面的代码转换成字节数组?如何转换为流?

FileInputStream in = new FileInputStream("C:\\Projects\\Experiments\\samplephotoCTS.jpg");

    ByteArrayOutputStream bos = new ByteArrayOutputStream();


    byte[] buffer = new byte[102400];
    for (int i; (i = in.read(buffer)) != -1; ) {
        bos.write(buffer, 0, i);
    }
    in.close();
    byte[] imageData = bos.toByteArray();
    bos.close();
    vars.put("imageData", new String(imageData));

0 个答案:

没有答案