我正在尝试使用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));