| | |
| | | import java.io.*; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | |
| | |
| | | } |
| | | |
| | | public static FileInfo generateBase64StringToFile(String fileString,int t,int type){ |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String format = sdf.format(new Date()); |
| | | String lastname= null; |
| | | //文件id |
| | | String uuid = UUID.randomUUID().toString().trim().replaceAll("-", ""); |
| | |
| | | }else { |
| | | lastname=".pdf"; |
| | | } |
| | | String filePath = "D:\\FFproject\\file\\"; |
| | | String filePath = "D:\\FFproject\\file\\"+format+"\\"; |
| | | if(fileString == null){ |
| | | return null; |
| | | }else { |
| | |
| | | // 创建链接 |
| | | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
| | | conn.setRequestMethod(requestMethod); |
| | | conn.setConnectTimeout(10 * 1000); |
| | | conn.setConnectTimeout(20000); |
| | | |
| | | if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { |
| | | //连接失败/链接失效/文件不存在 |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String get = netSourceToBase64("http://192.168.0.121:9999/admin/sys-file/platform/20230704154745.png", "GET"); |
| | | String get = netSourceToBase64("http://36.134.129.218:9999/admin/sys-file/platform/20230815083801.png", "GET"); |
| | | System.out.println(get); |
| | | } |
| | | |