### Question:
QRCodeUtils { public static void encode(String content, File file) throws Exception { MultiFormatWriter barcodeWriter = new MultiFormatWriter(); BitMatrix matrix = barcodeWriter.encode(content, BarcodeFormat.QR_CODE, DEFAULT_SIZE, DEFAULT_SIZE, encodeHints); if (!file.exists()) file.mkdirs(); String format = getFormat(file); MatrixToImageWriter.writeToFile(matrix, format, file); } private  QRCodeUtils(); static void encode(String content, File file); static void encode(String content, OutputStream stream, String format); static String decode(File file); static String decode(InputStream inputStream); static String decode(BufferedImage image); static String DEFAULT_ENCODE; static int DEFAULT_SIZE; static String DEFAULT_FORMAT; }### Answer:
@Test public void encodeToStream() throws Exception { String format = "png"; File file = new File("e:\\t\\zxing\\qrcode." + format); if (!file.exists()) file.mkdirs(); OutputStream stream = new FileOutputStream(file); String content = "http: QRCodeUtils.encode(content, stream, format); }
@Test public void encodeToPNGFile() throws Exception { File file = new File("e:\\t\\zxing\\qrcode.png"); String content = "http: QRCodeUtils.encode(content, file); }
@Test public void encodeToJPGFile() throws Exception { File file = new File("e:\\t\\zxing\\qrcode.jpg"); String content = "http: QRCodeUtils.encode(content, file); }