class FileCache {

	public FileCacheEntry addStream(InputStream is, TaskMonitor monitor)
			throws IOException, CancelledException {
		File tmpFile = new File(newDir, UUID.randomUUID().toString());
		try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
			StreamCopyResult copyResults = FSUtilities.streamCopy(is, fos, monitor);

			// Close the fos so the tmpFile can be moved even though
			// the try(){} will attempt to close it as well.
			fos.close();

			String md5 = NumericUtilities.convertBytesToString(copyResults.md5);

			return addTmpFileToCache(tmpFile, md5, copyResults.bytesCopied);
		}
		finally {
			if (tmpFile.exists()) {
				Msg.debug(this, "Removing left-over temp file " + tmpFile);
				tmpFile.delete();
			}
		}
	}

	public  FileCache(File cacheDir);

}