| | |
| | | hints.put(EncodeHintType.MARGIN, 0); |
| | | BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400, hints); |
| | | File file1 = new File(path, codeName + "." + imageType); |
| | | File parent = file1.getParentFile(); |
| | | if (parent != null && !parent.exists() && !parent.mkdirs()) { |
| | | throw new IOException("临时目录创建失败:" + parent.getPath()); |
| | | } |
| | | writeToFile(bitMatrix, imageType, file1); |
| | | return file1.getPath(); |
| | | } catch (WriterException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } catch (WriterException | IOException e) { |
| | | throw new RuntimeException("二维码生成失败:" + e.getMessage(), e); |
| | | } |
| | | throw new RuntimeException("二维码生成失败"); |
| | | } |
| | | |
| | | } |