code: public void putNextEntry(TarEntry entry) throws IOException {
          if (entry.getName().length() >= TarConstants.NAMELEN) {
  
              if (longFileMode == LONGFILE_GNU) {
                  // create a TarEntry for the LongLink, the contents
                  // of which are the entry's name
                  TarEntry longLinkEntry = new TarEntry(TarConstants.GNU_LONGLINK,
                                                        TarConstants.LF_GNUTYPE_LONGNAME);
  
                  byte[] name = entry.getName().getBytes(StandardCharsets.UTF_8);
                  longLinkEntry.setSize(name.length + 1);
                  putNextEntry(longLinkEntry);
                  write(name);
                  write(0);
                  closeEntry();
              } else if (longFileMode != LONGFILE_TRUNCATE) {
                  throw new RuntimeException("file name '" + entry.getName()
                                               + "' is too long ( > "
                                               + TarConstants.NAMELEN + " bytes)");
              }
          }
  
          entry.writeEntryHeader(this.recordBuf);
          this.buffer.writeRecord(this.recordBuf);
  
          this.currBytes = 0;
  
          if (entry.isDirectory()) {
              this.currSize = 0;
          } else {
              this.currSize = entry.getSize();
          }
          currName = entry.getName();
      }
docs: Put an entry on the output stream. This writes the entry's
  header record and positions the output stream for writing
  the contents of the entry. Once this method is called, the
  stream is ready for calls to write() to write the entry's
  contents. Once the contents are written, closeEntry()
  <B>MUST</B> be called to ensure that all buffered data
  is completely written to the output stream.
  
  @param entry The TarEntry to be written to the archive.
  @throws IOException on error