|
@@ -110,7 +110,7 @@ public class FileUtils {
|
|
|
|
|
|
URL url = new URL(dataUrl); //想要读取的url地址
|
|
|
InputStream in = url.openStream();
|
|
|
- File file = File.createTempFile("new_url", ".jpg"); //创建文件
|
|
|
+ File file = File.createTempFile("new_url", ".pdf"); //创建文件
|
|
|
OutputStream os = new FileOutputStream(file); //创建文件输出流
|
|
|
int bytesRead;
|
|
|
byte[] buffer = new byte[8192];
|
|
@@ -123,7 +123,23 @@ public class FileUtils {
|
|
|
in.close();
|
|
|
return file;
|
|
|
}
|
|
|
+ public static File getPictureFileByUrl(String dataUrl) throws IOException {
|
|
|
|
|
|
+ URL url = new URL(dataUrl); //想要读取的url地址
|
|
|
+ InputStream in = url.openStream();
|
|
|
+ File file = File.createTempFile("new_url", ".jpg"); //创建文件
|
|
|
+ OutputStream os = new FileOutputStream(file); //创建文件输出流
|
|
|
+ int bytesRead;
|
|
|
+ byte[] buffer = new byte[8192];
|
|
|
+ int len = 8192;
|
|
|
+ while ((bytesRead = in.read(buffer, 0, len)) != -1) {
|
|
|
+ os.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ //关闭释放流
|
|
|
+ os.close();
|
|
|
+ in.close();
|
|
|
+ return file;
|
|
|
+ }
|
|
|
public String getPath(String url) {
|
|
|
return getStaticPath(COMMON_FILE) + url;
|
|
|
}
|