Search in sources :

Example 6 with SyncFailedException

use of java.io.SyncFailedException in project baker-android by bakerframework.

the class DownloadThread method syncDestination.

/**
 * Sync the destination file to storage.
 */
private void syncDestination(State state) {
    FileOutputStream downloadedFileStream = null;
    try {
        downloadedFileStream = new FileOutputStream(state.mFilename, true);
        downloadedFileStream.getFD().sync();
    } catch (FileNotFoundException ex) {
        Log.w(Constants.TAG, "file " + state.mFilename + " not found: " + ex);
    } catch (SyncFailedException ex) {
        Log.w(Constants.TAG, "file " + state.mFilename + " sync failed: " + ex);
    } catch (IOException ex) {
        Log.w(Constants.TAG, "IOException trying to sync " + state.mFilename + ": " + ex);
    } catch (RuntimeException ex) {
        Log.w(Constants.TAG, "exception while syncing file: ", ex);
    } finally {
        if (downloadedFileStream != null) {
            try {
                downloadedFileStream.close();
            } catch (IOException ex) {
                Log.w(Constants.TAG, "IOException while closing synced file: ", ex);
            } catch (RuntimeException ex) {
                Log.w(Constants.TAG, "exception while closing file: ", ex);
            }
        }
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) SyncFailedException(java.io.SyncFailedException) IOException(java.io.IOException)

Aggregations

SyncFailedException (java.io.SyncFailedException)6 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)5 File (java.io.File)4 FileOutputStream (java.io.FileOutputStream)4 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)2 TransactionData (com.arjuna.ats.internal.arjuna.objectstore.LogInstance.TransactionData)1 ApduExecException (com.fitpay.android.paymentdevice.utils.ApduExecException)1 EventCallback (com.fitpay.android.utils.EventCallback)1 ContentFileNotFoundException (com.keepassdroid.database.exception.ContentFileNotFoundException)1 InvalidDBException (com.keepassdroid.database.exception.InvalidDBException)1 InvalidPasswordException (com.keepassdroid.database.exception.InvalidPasswordException)1 PwDbOutputException (com.keepassdroid.database.exception.PwDbOutputException)1 PwDbOutput (com.keepassdroid.database.save.PwDbOutput)1 FileDescriptor (java.io.FileDescriptor)1 OutputStream (java.io.OutputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 ParseException (java.text.ParseException)1