try { socket = new ServerSocket(sigPlace.PORT); System.out.println("Listening on port "+sigPlace.PORT+"."); while (true) { try (Socket client = socket.accept()) { System.out.println("New client connection detected: "+client.toString()); BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); String requestLine,line; ZonedDateTime modifiedDate = null; String boundary=null; boolean uploadData = false; boolean truncateUntilBoundary=false; String filename=null; requestLine=in.readLine(); //Read the first line, this should be our request. if (requestLine!=null) { String[] splitter = requestLine.split(Pattern.quote(" ")); boolean ISPOST = splitter[0].equals("POST"); if (splitter.length==3) { while (in.ready()) { line=in.readLine(); if (ISPOST) { if (boundary!=null) { if (!truncateUntilBoundary) { System.out.println(line); if (boundary.length()>0) { if (line.equals(boundary)) { truncateUntilBoundary=true; } } } else if (line.contains(boundary)) { System.out.println(""); System.out.println("<...>"); System.out.println(""); System.out.println(line); truncateUntilBoundary=false;