code: public synchronized void finish() {
          if (!isFinished) {
              isFinished = true;
              try {
                  writer.close();
                  // Re-open as a random access file so we can overwrite the 3 int
                  // header that specifies the number of dimensions and values.
                  // Note that the location of the matrix data is dependent on
                  // whether the matrix is to be transposed.
                  RandomAccessFile matrixRaf =
                      new RandomAccessFile(matrixFile, "rw");
  
                  // Write the header in the first 100 characters.  The header is
                  // the number rows, the number of columns, and the number of non
                  // zeros on a single line with spaces between them.
                  StringBuilder sb = new StringBuilder();
                  sb.append(curRow).append(" ");
                  sb.append(numCols).append(" ");
                  sb.append(nonZeroValues).append(" ");
                  matrixRaf.write(sb.toString().getBytes());
              } catch (IOException ioe) {
                  throw new IOError(ioe);
              }
          }
      }
docs: {@inheritDoc} Once this method has been called, any subsequent calls will
  have no effect and will not throw an exception.