4
4
import cn .keking .model .FileAttribute ;
5
5
import cn .keking .model .FileType ;
6
6
import cn .keking .model .ReturnResponse ;
7
+ import io .mola .galimatias .GalimatiasParseException ;
7
8
import org .slf4j .Logger ;
8
9
import org .slf4j .LoggerFactory ;
9
10
@@ -81,7 +82,6 @@ public static ReturnResponse<String> downLoad(FileAttribute fileAttribute, Strin
81
82
public static byte [] getBytesFromUrl (String urlStr ) throws IOException {
82
83
InputStream is = getInputStreamFromUrl (urlStr );
83
84
if (is == null ) {
84
- // urlStr = URLUtil.normalize(urlStr, true, true);
85
85
is = getInputStreamFromUrl (urlStr );
86
86
if (is == null ) {
87
87
logger .error ("文件下载异常:url:{}" , urlStr );
@@ -98,13 +98,14 @@ public static void saveBytesToOutStream(byte[] b, OutputStream os) throws IOExce
98
98
99
99
private static InputStream getInputStreamFromUrl (String urlStr ) {
100
100
try {
101
- URL url = new URL (urlStr );
101
+
102
+ URL url = io .mola .galimatias .URL .parse (urlStr ).toJavaURL ();
102
103
URLConnection connection = url .openConnection ();
103
104
if (connection instanceof HttpURLConnection ) {
104
105
connection .setRequestProperty ("User-Agent" , "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)" );
105
106
}
106
107
return connection .getInputStream ();
107
- } catch (IOException e ) {
108
+ } catch (IOException | GalimatiasParseException e ) {
108
109
logger .warn ("连接url异常:url:{}" , urlStr );
109
110
return null ;
110
111
}
0 commit comments