NutzCN Logo
问答 qrcode.toFile,保存文件保存
发布于 2785天前 作者 ecoolper 2560 次浏览 复制 上一个帖子 下一个帖子
标签:

qrcode.toFile,保存文件保存

		QRCode qrcode = QRCode.NEW("http://nutz.cn");
		qrcode.toFile("D:\\x5work\\BeX5_V3.5\\data\\qrcode\\c98a599835044604b995b6b3a486d101")
5 回复

报错日志

Exception in thread "main" java.lang.RuntimeException: Unexpected error writing image
	at org.nutz.qrcode.QRCode.toFile(QRCode.java:162)
	at org.nutz.qrcode.QRCode.toFile(QRCode.java:108)
	at com.zlz.service.QRCodeService.main(QRCodeService.java:42)

文件路径修改为:D:\x5work\BeX5_V3.5\data\qrcode\c98a599835044604b995b6b3a486d101.png,
正常,不报错

解决了,修改了下qrcode QRCode类的源码:

    private String getSuffixName(File file) {
        String name =file.getName();

        if (null == name) {
            return this.format.getImageFormat();
        }
        int pos = name.lastIndexOf('.');
        if (-1 == pos) {
            return this.format.getImageFormat();
        }
        return name.substring(pos + 1).toUpperCase();
    }

需要后缀。。。

来自炫酷的 NutzCN

现在不添加后缀名也可以了

添加回复
请先登陆
回到顶部