当前位置: 首页>>代码示例>>Java>>正文


Java HTTP.US_ASCII属性代码示例

本文整理汇总了Java中org.apache.http.protocol.HTTP.US_ASCII属性的典型用法代码示例。如果您正苦于以下问题:Java HTTP.US_ASCII属性的具体用法?Java HTTP.US_ASCII怎么用?Java HTTP.US_ASCII使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.http.protocol.HTTP的用法示例。


在下文中一共展示了HTTP.US_ASCII属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rebuildJournal

/**
 * Creates a new journal that omits redundant information. This replaces the
 * current journal if it exists.
 */
private synchronized void rebuildJournal() throws IOException {
    if (journalWriter != null) {
        IOUtils.closeQuietly(journalWriter);
    }

    Writer writer = null;
    try {
        writer = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(journalFileTmp), HTTP.US_ASCII));
        writer.write(MAGIC);
        writer.write("\n");
        writer.write(VERSION_1);
        writer.write("\n");
        writer.write(Integer.toString(appVersion));
        writer.write("\n");
        writer.write(Integer.toString(valueCount));
        writer.write("\n");
        writer.write("\n");

        for (Entry entry : lruEntries.values()) {
            if (entry.currentEditor != null) {
                writer.write(DIRTY + ' ' + entry.diskKey + '\n');
            } else {
                writer.write(CLEAN + ' ' + entry.diskKey + " t_" + entry.expiryTimestamp + entry.getLengths() + '\n');
            }
        }
    } finally {
        IOUtils.closeQuietly(writer);
    }

    if (journalFile.exists()) {
        renameTo(journalFile, journalFileBackup, true);
    }
    renameTo(journalFileTmp, journalFile, false);
    journalFileBackup.delete();

    journalWriter = new BufferedWriter(
            new OutputStreamWriter(new FileOutputStream(journalFile, true), HTTP.US_ASCII));
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:43,代码来源:LruDiskCache.java

示例2: open

/**
 * Opens the cache in {@code directory}, creating a cache if none exists
 * there.
 *
 * @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
 * @throws IOException if reading or writing the cache directory fails
 */
public static LruDiskCache open(File directory, int appVersion, int valueCount, long maxSize)
        throws IOException {
    if (maxSize <= 0) {
        throw new IllegalArgumentException("maxSize <= 0");
    }
    if (valueCount <= 0) {
        throw new IllegalArgumentException("valueCount <= 0");
    }

    // If a bkp file exists, use it instead.
    File backupFile = new File(directory, JOURNAL_FILE_BACKUP);
    if (backupFile.exists()) {
        File journalFile = new File(directory, JOURNAL_FILE);
        // If journal file also exists just delete backup file.
        if (journalFile.exists()) {
            backupFile.delete();
        } else {
            renameTo(backupFile, journalFile, false);
        }
    }

    // Prefer to pick up where we left off.
    LruDiskCache cache = new LruDiskCache(directory, appVersion, valueCount, maxSize);
    if (cache.journalFile.exists()) {
        try {
            cache.readJournal();
            cache.processJournal();
            cache.journalWriter = new BufferedWriter(
                    new OutputStreamWriter(new FileOutputStream(cache.journalFile, true), HTTP.US_ASCII));
            return cache;
        } catch (Throwable journalIsCorrupt) {
            LogUtils.e("DiskLruCache "
                    + directory
                    + " is corrupt: "
                    + journalIsCorrupt.getMessage()
                    + ", removing", journalIsCorrupt);
            cache.delete();
        }
    }

    // Create a new empty cache.
    directory.mkdirs();
    cache = new LruDiskCache(directory, appVersion, valueCount, maxSize);
    cache.rebuildJournal();
    return cache;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:55,代码来源:LruDiskCache.java


注:本文中的org.apache.http.protocol.HTTP.US_ASCII属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。