域名长度后缀删除日期删除类型 2012/9/4 Delete 今天朋友问我一个二维码的东西,说实话我重来也没接触过,于是上网找了一下,和朋友分享一下... 用 r 也能做, 但是一看小日本的, 于是马上闪过,听所 zxin g 挺好用的,于是就去 google 下了架包用了这个感觉确实简单,重百度找到写完一个例子只用了, 10 来分钟........ //ng 是 Google 提供的关于条码(一维码、二维码)的解析工具, 提供了二维码的生成与解析的方法,现在我简单介绍一下使用 Jav a 利用 Zxing 生成与解析二维码 1 、二维码的生成 将 包加入到 classpath 下。 二维码的生成需要借助 MatrixToImageWriter 类,该类是由 Google 提供的,可以将该类拷贝到源码中,这里我将该类的源码贴上,可以直接使用。[java] view plaincopyprint?.; import ; import ; import ; import ; import ; public final class MatrixToImageWriter { private static final int BLACK = 0xFF000000; private static final int WHITE = 0xFFFFFFFF; private MatrixToImageWriter() {} public static BufferedImage toBufferedImage(BitMatrix matrix) { int width = (); int height = (); BufferedImage image = new BufferedImage(width, height, ); for (int x= 0;x< width; x++) { for (int y= 0;y< height; y++) { (x, y, (x, y)? BLACK : WHITE); }} return image; } public static void writeToFile(BitMatrix matrix, String format, File file) throws IOException { BufferedImage image = toBufferedImage(matrix); if (!(image, format, file)) { throw new IOException("Could not write an image of format "+ format +" to"+ file); }} public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) throws IOException { BufferedImage image = toBufferedImage(matrix); if (!(image, format, stream)) { throw new IOException("Could not write an image of format "+ format); }}} .; import ; import ; import ; import ; import ; public final class MatrixToImageWriter { private static final int BLACK = 0xFF000000; private static final int WHITE = 0xFFFFFFFF; private MatrixToImageWriter() {} public stati
Java使用Zxing包制作二维码 来自淘豆网m.daumloan.com转载请标明出处.