I'm not very familiar with barcodes or barcode4j. I have a URL of the barcode and need to connect to that URL, stream it in order to make an image from it, then store that image somewhere on the file system.
does anyone have experience doing this with Barcode4J?
below i make the url...
private BarcodeRequestBean barCodeProcess(ResponseWithBarCode barCode)throws Exception
{
//hard coding bar code encoding and font size time being
String barCodeNum = ((ResponseWithBarCode)barCode).getBarCodeNumber();
logger.info("Please check below barcode generating parameters if generation failed:");
logger.info("BarCode Number = " + barCodeNum);
if (StringUtils.isEmpty(barCodeNum)||(barCodeNum==null))
{
throw new Exception("ResponseWithBarCode returned invalid barCodeNumber value!");
}
BarcodeRequestBean barbean = new BarcodeRequestBean();
//set bar code number
barbean.setMsg(barCodeNum); //reference number
//set default value
barbean.setType(config.getString("barcode.encoding")); //ex:code128
barbean.setHumanReadableSize(config.getString("barcode.font.size")); //ex:3pt
barbean.setWideFactor(config.getString("barcode.wide.factor")); //wide factor: 2
barbean.setFormat(config.getString("barcode.file.format")); //file format: png
barbean.setHeight(config.getString("barcode.height")); //heigh:1cm
barbean.setModuleWidth(config.getString("barcode.module.width")); //Module width: 0.15mm
return barbean;
}
I have a string of the url as such:
String genbc = barCodeProcess(barCode).toURL();
Perhaps you should learn to think more clear about your work.
Solving this issue, from what I understand, has nothing to do with bar codes. You have an image, that is available through an URL, and you must download it. That problem has been viewed many times on stack overflow and you would have found it if you did the search: "java downloading an image". It was the first result that came up for me in google.