code: public void close() throws IOException {
          switch (state) {
              case READY:
                  throw new IllegalStateException("File " + tempFile
                          + " hasn't been opened yet.");
              case CLOSED:
                  throw new IllegalStateException("File " + tempFile
                          + " has been closed already.");
              default: // OPEN
                  fileWriter.close();
                  tempFile.renameTo(file);
                  state = State.CLOSED;
          }
      }
docs: Close the writer and rename the file.
  
  @throws IOException