我要求放心的API-
https://www.qrtag.net/api/qr_10.png?url=https://www.halodoc.com
并获得响应,响应和QR码图像,如何将其存储在文件夹中。
您可以使用FileOutputStream。
String fileName = url.getFile();
String destName = "qr.png";
System.out.println(destName);
InputStream is = null;
try {
is = url.openStream();
} catch (IOException e) {
e.printStackTrace();
}
OutputStream os = new FileOutputStream(destName);
byte[] b = new byte[2048];
int length;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
}
is.close();
os.close();