/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.util.jbarcode;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import org.jbarcode.JBarcode;
import org.jbarcode.encode.EAN8Encoder;
import org.jbarcode.paint.EAN8TextPainter;
import org.jbarcode.paint.WidthCodedPainter;
import org.jbarcode.util.ImageUtil;
/**
* 支持EAN13, EAN8, UPCA, UPCE, Code 3 of 9, Codabar, Code 11, Code 93, Code 128, MSI/Plessey, Interleaved 2 of PostNet等
* 利用jbarcode生成各种条形码!测试成功!分享给大家!
*/
public class OneBarcodeUtil {
public static void main(String[] paramArrayOfString) {
try {
JBarcode localJBarcode = new JBarcode(EAN8Encoder.getInstance(),WidthCodedPainter.getInstance(),EAN8TextPainter.getInstance());
String str = "2219644";
BufferedImage localBufferedImage = localJBarcode.createBarcode(str);
saveToJPEG(localBufferedImage, "EAN.jpg");
}
catch (Exception localException) {
localException.printStackTrace();
}
}
static void saveToJPEG(BufferedImage paramBufferedImage, String paramString) {
saveToFile(paramBufferedImage, paramString, "jpeg");
}
static void saveToFile(BufferedImage paramBufferedImage, String paramString1, String paramString2) {
try {
FileOutputStream localFileOutputStream = new FileOutputStream("F:\\" + paramString1);
ImageUtil.encodeAndWrite(paramBufferedImage, paramString2, localFileOutputStream, 96, 96);
localFileOutputStream.close();
}
catch (Exception localException) {
localException.printStackTrace();
}
}
}
最近下载更多
LIU_NQ LV1
2024年11月18日
limengqiang LV1
2024年5月21日
huangbo28 LV1
2024年3月14日
1112WHQ LV7
2023年11月3日
768325867 LV1
2023年10月25日
zhujianfei123 LV1
2023年7月22日
qingye LV1
2023年6月16日
daniellyer LV1
2023年4月18日
liminshabi LV2
2023年4月14日
guaixia163 LV13
2023年2月26日

最近浏览
