public class BarCodeUtil extends Object
限定符和类型 | 字段和说明 |
---|---|
static String |
CHARSET |
static int |
CONTENT_MAX_LENGTH |
static String |
FORMAT
生成图片的格式
|
构造器和说明 |
---|
BarCodeUtil() |
限定符和类型 | 方法和说明 |
---|---|
static boolean |
checkContentLength(String content)
已过时。
|
static boolean |
checkContentLength(String content,
int maxLength)
判断生成的内容是否大于自定义的长度限制
|
static String |
decode(InputStream in)
根据输入流读取二维码内容
|
static void |
encode(String contents,
BarCodeParamVo paramVo,
File f)
为指定的内容生成二维码
|
static void |
encode(String contents,
BarCodeParamVo paramVo,
OutputStream out)
为指定的内容生成二维码
|
static int |
getStringLength(String content,
boolean needFormat)
获取字符串长度
|
static BarCodeTypeManager |
getTypeManager(String typeKey)
根据type key获取对应的实现类,
如果不存在,则返回默认实现
|
static BarCodeTypeManager |
getTypeManager(String typeKey,
boolean needDefault)
根据 type key 获取对应的实现类
|
static void |
init() |
public static final int CONTENT_MAX_LENGTH
public static void init()
public static BarCodeTypeManager getTypeManager(String typeKey)
typeKey
- keypublic static BarCodeTypeManager getTypeManager(String typeKey, boolean needDefault)
typeKey
- keyneedDefault
- 是否需要默认实现,当根据key查询对应的实现时,不存在时,否则返回nullpublic static void encode(String contents, BarCodeParamVo paramVo, OutputStream out) throws com.google.zxing.WriterException, IOException
contents
- 内容com.google.zxing.WriterException
IOException
public static void encode(String contents, BarCodeParamVo paramVo, File f) throws com.google.zxing.WriterException, IOException
contents
- 内容f
- 生成的文件com.google.zxing.WriterException
IOException
public static String decode(InputStream in) throws IOException, com.google.zxing.NotFoundException
in
- 二维码图片输入流IOException
com.google.zxing.NotFoundException
@Deprecated public static boolean checkContentLength(String content)
content
- 字符串public static boolean checkContentLength(String content, int maxLength)
content
- maxLength
- public static int getStringLength(String content, boolean needFormat)
content
- 字符串needFormat
- 是否需要做特殊处理:中文按照3个字符处理Copyright © 2016–2018. All rights reserved.