private void writeFile() throws IOException {
		// Make sure parent directory and file are ready
		synchronized (file) {
			if (!file.exists()) {
				file.getParentFile().mkdirs();
				file.createNewFile();
			}

			// Hooray Java 7 try resource closing!
			try (FileOutputStream fos = new FileOutputStream(file);
					ObjectOutputStream oos = new ObjectOutputStream(fos)) {

				synchronized (cacheLock) {
					oos.writeInt(autoincrement);
					oos.writeObject(cache);
				}
			} catch (IOException ex) {
				throw ex;
			}
		}
	}