code: public static long padLogFile(FileOutputStream f,long currentSize,
              long preAllocSize) throws IOException{
          long position = f.getChannel().position();
          if (position + 4096 >= currentSize) {
              currentSize = currentSize + preAllocSize;
              fill.position(0);
              f.getChannel().write(fill, currentSize-fill.remaining());
          }
          return currentSize;
      }
docs: Grows the file to the specified number of bytes. This only happenes if
  the current file position is sufficiently close (less than 4K) to end of
  file.
  
  @param f output stream to pad
  @param currentSize application keeps track of the cuurent file size
  @param preAllocSize how many bytes to pad
  @return the new file size. It can be the same as currentSize if no
  padding was done.
  @throws IOException