Browse Source
* commit '692d7d82c48d2cedb663e5d187f848b67029eaa3': 误提交了测试代码 无JIRA任务 完善提供的web容器API,简化加载jar包中html/js/css的方式bugfix/10.0
richie
6 years ago
6 changed files with 124 additions and 3 deletions
@ -0,0 +1,39 @@
|
||||
package com.fr.design.ui; |
||||
|
||||
import com.teamdev.jxbrowser.chromium.URLResponse; |
||||
|
||||
import java.io.DataInputStream; |
||||
import java.io.InputStream; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-03-07 |
||||
*/ |
||||
public class ModernUIAssist { |
||||
|
||||
public static URLResponse inputStream2Response(InputStream inputStream, String filePath) throws Exception { |
||||
URLResponse response = new URLResponse(); |
||||
DataInputStream stream = new DataInputStream(inputStream); |
||||
byte[] data = new byte[stream.available()]; |
||||
stream.readFully(data); |
||||
response.setData(data); |
||||
String mimeType = getMimeType(filePath); |
||||
response.getHeaders().setHeader("Content-Type", mimeType); |
||||
return response; |
||||
} |
||||
|
||||
|
||||
private static String getMimeType(String path) { |
||||
if (path.endsWith(".html")) { |
||||
return "text/html"; |
||||
} |
||||
if (path.endsWith(".css")) { |
||||
return "text/css"; |
||||
} |
||||
if (path.endsWith(".js")) { |
||||
return "text/javascript"; |
||||
} |
||||
return "text/html"; |
||||
} |
||||
} |
Loading…
Reference in new issue