private void write(final DataIdentifier identifier, final File file, final boolean async, final AsyncUploadCallback callback) throws DataStoreException { log("write " + identifier + " " + file.length()); byte[] buffer = new byte[(int) file.length()]; try { if (async && callback == null) { throw new IllegalArgumentException( "callback parameter cannot be null"); } DataInputStream din = new DataInputStream(new FileInputStream(file)); din.readFully(buffer); din.close(); data.put(identifier, buffer); timeMap.put(identifier, System.currentTimeMillis()); } catch (IOException e) { if (async) { callback.onAbort(new AsyncUploadResult(identifier, file)); } throw new DataStoreException(e); } if (async) { callback.onSuccess(new AsyncUploadResult(identifier, file)); } }