我想将原来图片保存在本地功能改成保存到服务器上String filename = "D:\\ScenePics\\Plate20210416165034669.jpg";
这个路径改写成网络地址http:\\8.140.107.161\\ScenePics\\Plate20210416165034669.jpg;SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String newName = sf.format(new Date());
FileOutputStream fout;
try {
// String filename = ".\\pic\\"+ new String(pAlarmer.sDeviceIP).trim() + "_"
// + newName+"_type["+strItsPlateResult.struPicInfo[i].byType+"]_ItsPlate.jpg";
String filename = "D:\\ScenePics\\Plate20210416165034669.jpg";
fout = new FileOutputStream(filename);
//将字节写入文件
long offset = 0;
ByteBuffer buffers = strItsPlateResult.struPicInfo[i].pBuffer.getByteBuffer(offset, strItsPlateResult.struPicInfo[i].dwDataLen);
byte [] bytes = new byte[strItsPlateResult.struPicInfo[i].dwDataLen];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}