Remove obsolete loading animation
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ReloadingPage.java
index 0c8f516..bc18816 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - ReloadingPage.java - Copyright © 2010–2015 David Roden
+ * Sone - ReloadingPage.java - Copyright © 2010–2016 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,11 +19,11 @@ package net.pterodactylus.sone.web;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
-import net.pterodactylus.util.io.Closer;
 import net.pterodactylus.util.io.StreamCopier;
 import net.pterodactylus.util.web.Page;
 import net.pterodactylus.util.web.Request;
@@ -72,16 +72,11 @@ public class ReloadingPage<REQ extends Request> implements Page<REQ> {
                String path = request.getUri().getPath();
                int lastSlash = path.lastIndexOf('/');
                String filename = path.substring(lastSlash + 1);
-               InputStream fileInputStream = new FileInputStream(new File(filesystemPath, filename));
-               if (fileInputStream == null) {
-                       return response.setStatusCode(404).setStatusText("Not found.");
-               }
-               OutputStream contentOutputStream = response.getContent();
-               try {
+               try (InputStream fileInputStream = new FileInputStream(new File(filesystemPath, filename));
+                       OutputStream contentOutputStream = response.getContent()) {
                        StreamCopier.copy(fileInputStream, contentOutputStream);
-               } finally {
-                       Closer.close(fileInputStream);
-                       Closer.close(contentOutputStream);
+               } catch (FileNotFoundException fnfe1) {
+                       return response.setStatusCode(404).setStatusText("Not found.");
                }
                return response.setStatusCode(200).setStatusText("OK").setContentType(mimeType);
        }