public static final String getValidHostFor(String host) {
   if (host == null || host.trim().isEmpty()) {
     return getIp();
   }
   String port = "";
   if (host.contains(":")) {
     if (!host.contains("]")) {
       port = host.substring(host.lastIndexOf(":"), host.length());
       host = host.substring(0, host.lastIndexOf(":"));
     } else {
       /*port = host.substring(host.indexOf("]"), host.length());
       if(port.startsWith("]")) {
       	port = port.substring(1);
       }
       host = host.substring(0, host.indexOf("]") + 1);*/
       return host /* + port*/;
     }
   }
   boolean isHostValid;
   try {
     isHostValid = InetAddress.getByName(host) != null;
   } catch (Throwable ignored) {
     isHostValid = false;
   }
   if (host.isEmpty() || !isHostValid) {
     JavaWebServer.println("\t--- Detected unresolved host: " + host); // host = getIp();
   }
   return host + port;
 }
 public final void writeToFile(File folder) throws IOException {
   if (folder == null || folder.isFile()) {
     throw new IllegalArgumentException(
         "File argument for method \"writeToFile\" must be a directory!");
   }
   if (!folder.exists()) {
     folder.mkdirs();
   }
   byte[] data = this.fileData.getBytesAndDispose();
   final int size = data.length;
   File file = new File(folder, this.fileName);
   JavaWebServer.println(
       "\tWriting FormData \""
           + this.name
           + "\"'s file named \""
           + this.fileName
           + "\" to disk...");
   try (FileOutputStream fos = new FileOutputStream(file, true)) {
     fos.write(data, 0, data.length);
     fos.flush();
   } catch (IOException e) {
     data = null;
     System.gc();
     throw e;
   } finally {
     data = null;
     System.gc();
   }
   if (file.isFile()) { // If it exists and is a file.
     JavaWebServer.println(
         "\tOperation successful. Wrote "
             + Functions.humanReadableByteCount(size, true, 2)
             + " bytes to disk.");
   } else {
     JavaWebServer.println("\tOperation failed! File does not appear to exist.(???)");
   }
 }