LJL-Futures-v1/solutions/001_creating_futures/src/main/java/com/lightbend/futures/FileBasedObjectStore.java
/**
     * Writes an object to a file in the file store.
     * @param id - The id of the object being written.
     * @param obj - The object to be written.
     * @return true if the write was successful, false if it failed.
     */
Writes an object to a file in the file store.
@param id - The id of the object being written.
@param obj - The object to be written.
@return true if the write was successful, false if it failed.
Writes an object to a file in the file store . @param id - The id of the object being written . @param obj - The object to be written . @return true if the write was successful false if it failed .
@Override
    public boolean write(UUID id, Object obj) {
        lock.writeLock().lock();
        File file = new File(storeFolder, id.toString());
        boolean result;
        try (
            FileOutputStream fileOut = new FileOutputStream(file);
            ObjectOutputStream out = new ObjectOutputStream(fileOut)
        ) {
            out.writeObject(obj);
            result = true;
        } catch (IOException ex) {
            result = false;
        } finally {
            lock.writeLock().unlock();
        }
        return result;
    }
@ Override public boolean write ( UUID id , Object obj ) { lock . writeLock ( ) . lock ( ) ; File file = new File ( storeFolder , id . toString ( ) ) ; boolean result ; try ( FileOutputStream fileOut = new FileOutputStream ( file ) ; ObjectOutputStream out = new ObjectOutputStream ( fileOut ) ) { out . writeObject ( obj ) ; result = true ; } catch ( IOException ex ) { result = false ; } finally { lock . writeLock ( ) . unlock ( ) ; } return result ; }
Writes an object to a file in the file store.
Writes an object to a file in the file store .