Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void sendAsset(HttpResponse response, String requestUrl){
- try {
- File fi = new File("src/resources/assets" + requestUrl);
- byte[] fileContent = Files.readAllBytes(fi.toPath());
- response.setContent(fileContent);
- String[] splitUrl = requestUrl.split("\\.");
- String type = splitUrl[splitUrl.length - 1];
- response.addHeader("Content-Type", (String)WebConstants.HTTP_CONTENT_TYPES.get(type));
- }catch (IOException e){
- response.setStatusCode(404);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement