Tabnine Logo
InFileInputStreamObjectPersister
Code IndexAdd Tabnine to your IDE (free)

How to use
InFileInputStreamObjectPersister
in
com.octo.android.robospice.persistence.binary

Best Java code snippets using com.octo.android.robospice.persistence.binary.InFileInputStreamObjectPersister (Showing top 3 results out of 315)

origin: com.octo.android.robospice/robospice-cache

@Override
public InputStream saveDataToCacheAndReturnData(InputStream data, final Object cacheKey) throws CacheSavingException {
  // special case for inputstream object : as it can be read only
  // once,
  // 0) we extract the content of the input stream as a byte[]
  // 1) we save it in file asynchronously if enabled
  // 2) the result will be a new InputStream on the byte[]
  final byte[] byteArray;
  try {
    byteArray = IOUtils.toByteArray(data);
    if (isAsyncSaveEnabled()) {
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
          } catch (IOException e) {
            Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
          }
        };
      };
      t.start();
    } else {
      FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
    }
    return new ByteArrayInputStream(byteArray);
  } catch (IOException e) {
    throw new CacheSavingException(e);
  }
}
origin: com.octo.android.robospice/robospice-sample

@Override
public CacheManager createCacheManager(Application application) {
  CacheManager cacheManager = new CacheManager();
  // init
  InFileStringObjectPersister inFileStringObjectPersister = new InFileStringObjectPersister(application);
  InFileInputStreamObjectPersister inFileInputStreamObjectPersister = new InFileInputStreamObjectPersister(application);
  JacksonObjectPersisterFactory inJSonFileObjectPersisterFactory = new JacksonObjectPersisterFactory(application);
  inFileStringObjectPersister.setAsyncSaveEnabled(true);
  inFileInputStreamObjectPersister.setAsyncSaveEnabled(true);
  inJSonFileObjectPersisterFactory.setAsyncSaveEnabled(true);
  cacheManager.addPersister(inFileStringObjectPersister);
  cacheManager.addPersister(inFileInputStreamObjectPersister);
  cacheManager.addPersister(inJSonFileObjectPersisterFactory);
  return cacheManager;
}
origin: com.octo.android.robospice/robospice-cache

  @Override
  public void run() {
    try {
      FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
    } catch (IOException e) {
      Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
    }
  };
};
com.octo.android.robospice.persistence.binaryInFileInputStreamObjectPersister

Most used methods

  • <init>
  • getCacheFile
  • isAsyncSaveEnabled
  • setAsyncSaveEnabled

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • onCreateOptionsMenu (Activity)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Permission (java.security)
    Legacy security code; do not use.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • JPanel (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now