Code example for ByteArrayInputStream

0
        Application application = (Application) getInstrumentation().getTargetContext().getApplicationContext();
        inputStreamCacheManager = new InFileBigInputStreamObjectPersister(application);
    } 
 
    public void testSaveDataToCacheAndReturnData() throws Exception { 
        inputStreamCacheManager.saveDataToCacheAndReturnData(new ByteArrayInputStream("coucou".getBytes()), TEST_CACHE_KEY);
 
        File cachedFile = inputStreamCacheManager.getCacheFile(TEST_CACHE_KEY);
        assertTrue(cachedFile.exists());
 
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        IOUtils.copy(new FileInputStream(cachedFile), bos);
        assertTrue(Arrays.equals("coucou".getBytes(), bos.toByteArray()));
    } 
 
    public void testLoadDataFromCache_no_expiracy() throws Exception { 
        File cachedFile = inputStreamCacheManager.getCacheFile(TEST_CACHE_KEY);
        IOUtils.write("coucou", new FileOutputStream(cachedFile));
 
        InputStream inputStream = inputStreamCacheManager.loadDataFromCache(TEST_CACHE_KEY, DurationInMillis.ALWAYS);
Stop searching for code, let great code find you!  Add Codota to your java IDE