首页>代码>jAVA生成条形码 >/jbarcode/src/com/util/jbarcode/OneBarcodeUtil.java
/* 
    * 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();  
         }  
     }  
   }
最近下载更多
huangbo28  LV1 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日
1211413075  LV14 2023年1月31日
pangxixin  LV6 2023年1月31日
最近浏览更多
huangbo28  LV1 3月14日
蔡雨生 3月6日
暂无贡献等级
1112WHQ  LV7 2023年11月3日
768325867  LV1 2023年10月25日
zhujianfei123  LV1 2023年7月22日
qingye  LV1 2023年6月16日
crosa_Don  LV18 2023年5月22日
zxsyaa  LV1 2023年5月10日
daniellyer  LV1 2023年4月18日
1358865648 2023年4月14日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友