當前位置: 首頁>>代碼示例>>Java>>正文


Java Charsets.US_ASCII屬性代碼示例

本文整理匯總了Java中com.google.common.base.Charsets.US_ASCII屬性的典型用法代碼示例。如果您正苦於以下問題:Java Charsets.US_ASCII屬性的具體用法?Java Charsets.US_ASCII怎麽用?Java Charsets.US_ASCII使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.google.common.base.Charsets的用法示例。


在下文中一共展示了Charsets.US_ASCII屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeTextualCheckpoints

private static void writeTextualCheckpoints(TreeMap<Integer, StoredBlock> checkpoints, File file) throws IOException {
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), Charsets.US_ASCII));
    writer.println("TXT CHECKPOINTS 1");
    writer.println("0"); // Number of signatures to read. Do this later.
    writer.println(checkpoints.size());
    ByteBuffer buffer = ByteBuffer.allocate(StoredBlock.COMPACT_SERIALIZED_SIZE);
    for (StoredBlock block : checkpoints.values()) {
        block.serializeCompact(buffer);
        writer.println(CheckpointManager.BASE64.encode(buffer.array()));
        buffer.position(0);
    }
    writer.close();
    System.out.println("Checkpoints written to '" + file.getCanonicalPath() + "'.");
}
 
開發者ID:creativechain,項目名稱:creacoinj,代碼行數:14,代碼來源:BuildCheckpoints.java

示例2: encode

public static String encode(byte[] input) {
    if (input.length == 0)
        return "";

    input = copyOfRange(input, 0, input.length);

    // Count leading zeroes.
    int zeroCount = 0;
    while (zeroCount < input.length && input[zeroCount] == 0)
        ++zeroCount;

    // The actual encoding.
    final byte[] temp = new byte[input.length * 2];
    int j = temp.length;

    int startAt = zeroCount;
    while (startAt < input.length) {
        byte mod = divmod43(input, startAt);
        if (input[startAt] == 0)
            ++startAt;
        temp[--j] = (byte) ALPHABET[mod];
    }

    // Strip extra '1' if there are some after decoding.
    while (j < temp.length && temp[j] == ALPHABET[0])
        ++j;

    // Add as many leading '1' as there were leading zeros.
    while (--zeroCount >= 0)
        temp[--j] = (byte) ALPHABET[0];

    final byte[] output = copyOfRange(temp, j, temp.length);

    return new String(output, Charsets.US_ASCII);
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:35,代碼來源:Base43.java

示例3: main

public static void main(String[] arg) throws IOException {
	if (arg.length == 0) {
		System.err.println("Usage: " + BuildRepetitionSet.class.getSimpleName() + " REPETITIONSET");
		System.exit(1);
	}

	final FastBufferedReader fastBufferedReader = new FastBufferedReader(new InputStreamReader(System.in, Charsets.US_ASCII));
	final MutableString s = new MutableString();
	final LongOpenHashSet repeatedSet = new LongOpenHashSet();
	final String outputFilename = arg[0];
	final ProgressLogger pl = new ProgressLogger();

	MutableString lastUrl = new MutableString();
	pl.itemsName = "lines";
	pl.start("Reading... ");
	while(fastBufferedReader.readLine(s) != null) {
		final int firstTab = s.indexOf('\t');
		final int secondTab = s.indexOf('\t', firstTab + 1);
		MutableString url = s.substring(secondTab + 1);
		if (url.equals(lastUrl)) {
			final int storeIndex = Integer.parseInt(new String(s.array(), 0, firstTab));
			final long storePosition = Long.parseLong(new String(s.array(), firstTab + 1, secondTab - firstTab - 1));
			repeatedSet.add((long)storeIndex << 48 | storePosition);
			System.out.print(storeIndex);
			System.out.print('\t');
			System.out.print(storePosition);
			System.out.print('\t');
			System.out.println(url);
		}

		lastUrl = url;
		pl.lightUpdate();
	}

	pl.done();

	fastBufferedReader.close();
	BinIO.storeObject(repeatedSet, outputFilename);
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:39,代碼來源:BuildRepetitionSet.java

示例4: main

public static void main(String arg[]) throws IOException {
	char[][] robotsResult = URLRespectsRobots.parseRobotsReader(new FileReader(arg[0]), arg[1]);
	for(char[] a: robotsResult) System.err.println(new String(a));
	final FastBufferedReader in = new FastBufferedReader(new InputStreamReader(System.in, Charsets.US_ASCII));
	final MutableString s = new MutableString();
	while(in.readLine(s) != null) {
		final URI uri = BURL.parse(s);
		System.out.println(apply(robotsResult, uri) + "\t" + uri);
	}
	in.close();

}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:12,代碼來源:URLRespectsRobots.java


注:本文中的com.google.common.base.Charsets.US_ASCII屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。