本文整理汇总了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() + "'.");
}
示例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);
}
示例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);
}
示例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();
}