private File createTempFile() throws IOException { File file = File.createTempFile("QRCode", "." + imageType.toString().toLowerCase()); file.deleteOnExit(); return file; }
private File createTempFile(String name) throws IOException { File file = File.createTempFile(name, "." + imageType.toString().toLowerCase()); file.deleteOnExit(); return file; } }
private void writeToStream(OutputStream stream) throws IOException, WriterException { MatrixToImageWriter.writeToStream(createMatrix(), imageType.toString(), stream); }
/** * returns a {@link File} representation of the QR code. The file is set to be deleted on exit (i.e. {@link * java.io.File#deleteOnExit()}). If you want the file to live beyond the life of the jvm process, you should make a copy. * * @return qrcode as file */ public File file() { File file; try { file = createTempFile(); MatrixToImageWriter.writeToPath(createMatrix(), imageType.toString(), file.toPath()); } catch (Exception e) { throw new QRGenerationException("Failed to create QR image from text due to underlying exception", e); } return file; }
/** * returns a {@link File} representation of the QR code. The file has the given name. The file is set to be deleted on exit * (i.e. {@link java.io.File#deleteOnExit()}). If you want the file to live beyond the life of the jvm process, you should * make a copy. * * @param name name of the created file * @return qrcode as file * @see #file() */ public File file(String name) { File file; try { file = createTempFile(name); MatrixToImageWriter.writeToPath(createMatrix(), imageType.toString(), file.toPath()); } catch (Exception e) { throw new QRGenerationException("Failed to create QR image from text due to underlying exception", e); } return file; }