code: public static int getFileNameBytes(String newName, byte[] outbuf) throws InvalidHeaderException {
          if (newName.length() > 100) {
              // Locate a pathname "break" prior to the maximum name length...
              int index = newName.indexOf("/", newName.length() - 100);
              if (index == -1) {
                  throw new InvalidHeaderException("file name is greater than 100 characters, " + newName);
              }
  
              // Get the "suffix subpath" of the name.
              String name = newName.substring(index + 1);
  
              // Get the "prefix subpath", or "prefix", of the name.
              String prefix = newName.substring(0, index);
              if (prefix.length() > TarHeader.PREFIXLEN) {
                  throw new InvalidHeaderException("file prefix is greater than 155 characters");
              }
  
              TarHeader.getNameBytes(new StringBuffer(name), outbuf, TarHeader.NAMEOFFSET, TarHeader.NAMELEN);
  
              TarHeader.getNameBytes(new StringBuffer(prefix), outbuf, TarHeader.PREFIXOFFSET, TarHeader.PREFIXLEN);
          } else {
              TarHeader.getNameBytes(new StringBuffer(newName), outbuf, TarHeader.NAMEOFFSET, TarHeader.NAMELEN);
          }
  
          // The offset, regardless of the format, is now the end of the
          // original name field.
          //
          return TarHeader.NAMELEN;
      }
docs: This method, like getNameBytes(), is intended to place a name into a TarHeader's buffer. However, this method is
  sophisticated enough to recognize long names (name.length() > NAMELEN). In these cases, the method will break the
  name into a prefix and suffix and place the name in the header in 'ustar' format. It is up to the TarEntry to
  manage the "entry header format". This method assumes the name is valid for the type of archive being generated.
  
  @param outbuf
  The buffer containing the entry header to modify.
  @param newName
  The new name to place into the header buffer.
  @return The current offset in the tar header (always TarHeader.NAMELEN).
  @throws InvalidHeaderException
  If the name will not fit in the header.