本文整理汇总了Java中okhttp3.internal.io.FileSystem类的典型用法代码示例。如果您正苦于以下问题:Java FileSystem类的具体用法?Java FileSystem怎么用?Java FileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystem类属于okhttp3.internal.io包,在下文中一共展示了FileSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
/**
* Create a cache which will reside in {@code directory}. This cache is lazily initialized on
* first access and will be created if it does not exist.
*
* @param directory a writable directory
* @param valueCount the number of values per cache entry. Must be positive.
* @param maxSize the maximum number of bytes this cache should use to store
*/
public static DiskLruCache create(FileSystem fileSystem, File directory, int appVersion,
int valueCount, long maxSize) {
if (maxSize <= 0) {
throw new IllegalArgumentException("maxSize <= 0");
}
if (valueCount <= 0) {
throw new IllegalArgumentException("valueCount <= 0");
}
// Use a single background thread to evict entries.
Executor executor = new ThreadPoolExecutor(0, 1, 60L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(), Util.threadFactory("OkHttp DiskLruCache", true));
return new DiskLruCache(fileSystem, directory, appVersion, valueCount, maxSize, executor);
}
示例2: prefetchFileSystemWriteFailure
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
@Test public void prefetchFileSystemWriteFailure() throws IOException {
FaultyHttpCacheStore faultyCacheStore = new FaultyHttpCacheStore(FileSystem.SYSTEM);
cacheStore.delegate = faultyCacheStore;
faultyCacheStore.failStrategy(FaultyHttpCacheStore.FailStrategy.FAIL_HEADER_WRITE);
server.enqueue(mockResponse("HttpCacheTestAllPlanets.json"));
Rx2Apollo.from(apolloClient.prefetch(new AllPlanetsQuery()))
.test()
.awaitDone(TIME_OUT_SECONDS, TimeUnit.SECONDS)
.assertError(Exception.class);
checkNoCachedResponse();
server.enqueue(mockResponse("HttpCacheTestAllPlanets.json"));
faultyCacheStore.failStrategy(FaultyHttpCacheStore.FailStrategy.FAIL_BODY_WRITE);
Rx2Apollo.from(apolloClient.prefetch(new AllPlanetsQuery()))
.test()
.awaitDone(TIME_OUT_SECONDS, TimeUnit.SECONDS)
.assertError(Exception.class);
checkNoCachedResponse();
}
示例3: DiskLruCache
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
DiskLruCache(FileSystem fileSystem, File directory, int appVersion, int valueCount, long maxSize,
Executor executor) {
this.fileSystem = fileSystem;
this.directory = directory;
this.appVersion = appVersion;
this.journalFile = new File(directory, JOURNAL_FILE);
this.journalFileTmp = new File(directory, JOURNAL_FILE_TEMP);
this.journalFileBackup = new File(directory, JOURNAL_FILE_BACKUP);
this.valueCount = valueCount;
this.maxSize = maxSize;
this.executor = executor;
}
示例4: LruDisk
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
@SuppressWarnings("ResultOfMethodCallIgnored")
LruDisk(File path, int version, int valueCount, int maxSize) {
if (!path.exists()) {
path.mkdirs();
}
gson = new Gson();
diskLruCache = DiskLruCache.create(FileSystem.SYSTEM, path, version, valueCount, maxSize);
}
示例5: SimpleCache
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
public SimpleCache(File directory, long maxSize) {
cache = DiskLruCache.create(FileSystem.SYSTEM, directory, VERSION, 2, maxSize);
}
示例6: createInMemoryCache
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
private static Cache createInMemoryCache() {
try {
final Constructor<Cache> constructor =
Cache.class.getDeclaredConstructor(File.class, Long.TYPE, FileSystem.class);
constructor.setAccessible(true);
return constructor.newInstance(
new File(".virtual"), 128*1024*1024, new InMemoryFileSystem()
);
}
catch (final Exception e) {
throw new RuntimeException(e);
}
}
示例7: fileSystemWriteFailure
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
@Test public void fileSystemWriteFailure() throws Exception {
enqueueResponse("/ShopWithCollections.json");
FaultyCacheStore faultyCacheStore = new FaultyCacheStore(FileSystem.SYSTEM);
cacheStore.delegate = faultyCacheStore;
faultyCacheStore.failStrategy(FaultyCacheStore.FailStrategy.FAIL_HEADER_WRITE);
GraphResponse response = graphClient.queryGraph(Storefront.query(new ShopWithCollectionsQuery()))
.cachePolicy(HttpCachePolicy.NETWORK_FIRST.expireAfter(10, TimeUnit.SECONDS))
.execute();
assertThat(server.getRequestCount()).isEqualTo(1);
assertThat(lastHttResponse.cacheResponse()).isNull();
assertThat(response.hasErrors()).isFalse();
assertThat(response.data()).isNotNull();
checkNoCachedResponse();
enqueueResponse("/ShopWithCollections.json");
faultyCacheStore.failStrategy(FaultyCacheStore.FailStrategy.FAIL_BODY_WRITE);
response = graphClient.queryGraph(Storefront.query(new ShopWithCollectionsQuery()))
.cachePolicy(HttpCachePolicy.NETWORK_FIRST.expireAfter(10, TimeUnit.SECONDS))
.execute();
assertThat(server.getRequestCount()).isEqualTo(2);
assertThat(lastHttResponse.cacheResponse()).isNull();
assertThat(response.hasErrors()).isFalse();
assertThat(response.data()).isNotNull();
checkNoCachedResponse();
}
示例8: Cache
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
public Cache(File directory, long maxSize) {
this(directory, maxSize, FileSystem.SYSTEM);
}
示例9: FaultyFileSystem
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
public FaultyFileSystem(FileSystem delegate) {
this.delegate = delegate;
}
示例10: Cache
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
public Cache(File directory, long maxSize) {
this(directory, maxSize, FileSystem.SYSTEM);
}
示例11: PicassoCardRequestHandler
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
private PicassoCardRequestHandler() {
File file = new File(ArcaneTrackerApplication.getContext().getCacheDir(), "cardsCache");
cache = DiskLruCache.create(FileSystem.SYSTEM, file, VERSION, ENTRY_COUNT, 250 * 1024*1024);
}
示例12: DiskLruHttpCacheStore
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
public DiskLruHttpCacheStore(@Nonnull File directory, long maxSize) {
this.cache = DiskLruCache.create(FileSystem.SYSTEM, directory, VERSION, ENTRY_COUNT, maxSize);
}
示例13: FaultyHttpCacheStore
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
FaultyHttpCacheStore(FileSystem fileSystem) {
this.cache = DiskLruCache.create(fileSystem, new File("/cache/"), VERSION, ENTRY_COUNT, Integer.MAX_VALUE);
}
示例14: ImageCache
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
private ImageCache(Context context) {
mDiskCache = DiskLruCache.create(FileSystem.SYSTEM, new File(context.getCacheDir(), context.getString(R.string.image_cache_name)),
BuildConfig.VERSION_CODE, 1, R.integer.google_plus_contact_image_cache_max_size);
mCache = new LruCache<>(R.integer.google_plus_contacts_cache_size);
}
示例15: DiskLruCacheStore
import okhttp3.internal.io.FileSystem; //导入依赖的package包/类
DiskLruCacheStore(@NonNull final File directory, final long maxSize) {
this.cache = DiskLruCache.create(FileSystem.SYSTEM, directory, VERSION, ENTRY_COUNT, maxSize);
}