当前位置: 首页>>代码示例>>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;未经允许,请勿转载。