當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。