10.31开发

This commit is contained in:
hejinbo
2023-10-31 19:15:46 +08:00
parent 580901e91c
commit 2238224e83
7 changed files with 495 additions and 58 deletions
@@ -0,0 +1,37 @@
package com.ruoyi.wisdomarbitrate.utils;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
public class MyTest {
public static void download(String fileUrl, String saveFilePath) throws IOException {
URL url = new URL(fileUrl);
InputStream inputStream = url.openStream();
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
FileOutputStream fileOutputStream = new FileOutputStream(saveFilePath);
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = bufferedInputStream.read(buffer, 0, buffer.length)) != -1) {
fileOutputStream.write(buffer, 0, bytesRead);
}
fileOutputStream.close();
bufferedInputStream.close();
inputStream.close();
}
public static void main(String[] args) {
String fileUrl = "https://esignoss.esign.cn/1111563786/0e16cc53-fe2e-403b-b901-587778a8ea92/3ed8f1b0bd2640e895fcfbaffdec0a1e.pdf?Expires=1698742492&OSSAccessKeyId=LTAI4G23YViiKnxTC28ygQzF&Signature=K%2Bb5k7DqNmaxeu%2Fct5qis4qor7s%3D";
String saveFilePath = "D:\\home\\example.pdf";
try {
download(fileUrl, saveFilePath);
System.out.println("File downloaded successfully.");
} catch (IOException e) {
e.printStackTrace();
}
}
}