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.(???)");
   }
 }
  private final void updateLabel() {
    if (this.isDisposed()) {
      return;
    }
    this.lblActiveConnection.setBounds(
        10, 5, this.getSize().x - 24, 37); // lblActiveConnection.setBounds(10, 5, 379, 37);
    String labelStr;
    if (this.status instanceof ClientInfo) {
      ClientInfo info = (ClientInfo) this.status;
      labelStr =
          "Client Info: "
              + info.getClientAddress()
              + "; Host used: \""
              + info.clientRequest.host
              + "\"; "
              + info.requestedFile.toString()
              + "; Data: "
              + Functions.humanReadableByteCount(info.requestedFile.bytesTransfered, true, 2)
              + " / "
              + Functions.humanReadableByteCount(
                  new Long(info.requestedFile.contentLength).longValue(), true, 2)
              + "; Data Transfer Rate: "
              + Functions.humanReadableByteCount(info.requestedFile.lastWriteAmount * 5L, true, 2)
              + "/sec";
      info.requestedFile.updateTime = 1000L / 5L; // 200 milliseconds
    } else {
      labelStr =
          "Client Info: "
              + this.status.getClientAddress()
              + "; Data: "
              + Functions.humanReadableByteCount(this.status.getCount(), true, 2)
              + " / "
              + Functions.humanReadableByteCount(
                  new Long(this.status.getContentLength()).longValue(), true, 2)
              + " uploaded;";
      if (this.status instanceof ClientRequestStatus) {
        ClientRequestStatus status = (ClientRequestStatus) this.status;
        labelStr += " Status: \"" + status.getStatus() + "\";";
        if (status.getFileName() != null) {
          labelStr += " File name: \"" + status.getFileName() + "\";";
        }
        final long timeTaken = status.getDataTransferElapsedTime();
        final long bytesPerSecond = status.getLastReadAmount() * 5L;
        labelStr +=
            "Data Transfer Rate: "
                + Functions.humanReadableByteCount(bytesPerSecond, true, 2)
                + "/sec";
        final long currentData = status.getCount();
        final long length = status.getContentLength();

        if (bytesPerSecond != 0 && currentData != 0) {
          final long secondsRemaining1 = (length - currentData) / bytesPerSecond;
          final long secondsRemaining2 =
              (timeTaken / currentData)
                  * (length - currentData); // (TimeTaken.TotalSeconds / totalBytesCopied) *
          // (totalFileSizeToCopy - totalBytesCopied);

          final double averageSecondsRemaining =
              ((secondsRemaining1 + secondsRemaining2) / 2L) / 10.0D;
          labelStr +=
              "; Estimated Time Remaining: "
                  + StringUtils.getElapsedTime(Math.round(averageSecondsRemaining * 1000.0D));
        }
      }
    }
    labelStr =
        labelStr.replace("&", "&&")
            + " Elapsed time: "
            + StringUtils.getElapsedTime(System.currentTimeMillis() - this.status.getStartTime());
    if (this.status instanceof ClientInfo) {
      labelStr +=
          "; Last write time: "
              + StringUtils.getElapsedTime(
                  System.currentTimeMillis() - ((ClientInfo) this.status).getLastWriteTime());
    } else if (this.status instanceof ClientRequestStatus) {
      final ClientRequestStatus status = (ClientRequestStatus) this.status;
      if (status.isProxyRequest()) {
        labelStr +=
            "; Last C-to-S write time: "
                + StringUtils.getElapsedTime(System.currentTimeMillis() - status.getLastReadTime());
        labelStr +=
            "; Last S-to-C write time: "
                + StringUtils.getElapsedTime(
                    System.currentTimeMillis() - status.getLastWriteTime());
      } else {
        labelStr +=
            "; Last read time: "
                + StringUtils.getElapsedTime(System.currentTimeMillis() - status.getLastReadTime());
      }
    }
    this.lblActiveConnection.setText(labelStr);
  }