diff --git a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java index 0c108b4ec3..4b5521c86b 100644 --- a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java +++ b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java @@ -286,21 +286,24 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler") .append("
  • ..
  • \r\n"); - for (File f: dir.listFiles()) { - if (f.isHidden() || !f.canRead()) { - continue; - } + File[] files = dir.listFiles(); + if (files != null) { + for (File f: files) { + if (f.isHidden() || !f.canRead()) { + continue; + } - String name = f.getName(); - if (!ALLOWED_FILE_NAME.matcher(name).matches()) { - continue; - } + String name = f.getName(); + if (!ALLOWED_FILE_NAME.matcher(name).matches()) { + continue; + } - buf.append("
  • ") - .append(name) - .append("
  • \r\n"); + buf.append("
  • ") + .append(name) + .append("
  • \r\n"); + } } buf.append("\r\n");