• Java生成各种条形码


     1 import java.awt.image.BufferedImage;  
     2 import java.io.FileOutputStream;  
     3 import org.jbarcode.JBarcode;  
     4 import org.jbarcode.encode.EAN8Encoder;
     5 import org.jbarcode.paint.EAN8TextPainter;
     6 import org.jbarcode.paint.WidthCodedPainter;  
     7 import org.jbarcode.util.ImageUtil;  
     8 /** 
     9  * 支持EAN13, EAN8, UPCA, UPCE, Code 3 of 9, Codabar, Code 11, Code 93, Code 128, MSI/Plessey, Interleaved 2 of PostNet等
    10  * 利用jbarcode生成各种条形码!测试成功!分享给大家!
    11  */ 
    12 public class OneBarcodeUtil {  
    13  
    14     public static void main(String[] paramArrayOfString) {  
    15         try {  
    16             JBarcode localJBarcode = new JBarcode(EAN8Encoder.getInstance(),WidthCodedPainter.getInstance(),EAN8TextPainter.getInstance());  
    17             String str = "2219644";  
    18             BufferedImage localBufferedImage = localJBarcode.createBarcode(str);  
    19              
    20             saveToGIF(localBufferedImage, "EAN8.jpg");
    21         }  
    22         catch (Exception localException) {  
    23             localException.printStackTrace();  
    24         }  
    25     }  
    26  
    27     static void saveToJPEG(BufferedImage paramBufferedImage, String paramString) {  
    28         saveToFile(paramBufferedImage, paramString, "jpeg");  
    29     }  
    30  
    31     static void saveToFile(BufferedImage paramBufferedImage, String paramString1, String paramString2) {  
    32         try {  
    33             FileOutputStream localFileOutputStream = new FileOutputStream("C:\Users\Administrator\Desktop/" + paramString1);  
    34             ImageUtil.encodeAndWrite(paramBufferedImage, paramString2, localFileOutputStream, 96, 96);  
    35             localFileOutputStream.close();  
    36         }  
    37         catch (Exception localException) {  
    38             localException.printStackTrace();  
    39         }  
    40     }  
    41 }
  • 相关阅读:
    CSS
    人物
    CSS
    CSS
    概念- 工业4.0
    C#正则表达式
    六月定律
    c#中实现登陆窗口(无需隐藏)
    c#中关于String、string,Object、object,Int32、int
    一个快速找第k+1小的算法
  • 原文地址:https://www.cnblogs.com/lr393993507/p/5543077.html
Copyright © 2020-2023  润新知