本文整理汇总了Java中com.google.common.base.Charsets.ISO_8859_1属性的典型用法代码示例。如果您正苦于以下问题:Java Charsets.ISO_8859_1属性的具体用法?Java Charsets.ISO_8859_1怎么用?Java Charsets.ISO_8859_1使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.common.base.Charsets
的用法示例。
在下文中一共展示了Charsets.ISO_8859_1属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeIniFile
/**
* Writes a .ini file from a set of properties, using UTF-8 encoding.
* The keys are sorted.
* The file should be read back later by {@link #parseIniFile(IAbstractFile, ILogger)}.
*
* @param iniFile The file to generate.
* @param values The properties to place in the ini file.
* @param addEncoding When true, add a property {@link #AVD_INI_ENCODING} indicating the
* encoding used to write the file.
* @throws IOException if {@link FileWriter} fails to open, write or close the file.
*/
private static void writeIniFile(File iniFile, Map<String, String> values, boolean addEncoding)
throws IOException {
Charset charset = Charsets.ISO_8859_1;
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(iniFile), charset);
if (addEncoding) {
// Write down the charset used in case we want to use it later.
writer.write(String.format("%1$s=%2$s\n", AVD_INI_ENCODING, charset.name()));
}
ArrayList<String> keys = new ArrayList<String>(values.keySet());
Collections.sort(keys);
for (String key : keys) {
String value = values.get(key);
writer.write(String.format("%1$s=%2$s\n", key, value));
}
writer.close();
}
示例2: addBlackListedIPv4
/** Adds a (or a set of) new IPv4 to the black list; the IPv4 can be specified directly or it can be a file (prefixed by
* <code>file:</code>).
*
* @param spec the specification (an IP address, or a file prefixed by <code>file</code>).
* @throws ConfigurationException
* @throws FileNotFoundException
*/
public void addBlackListedIPv4(final String spec) throws ConfigurationException, FileNotFoundException {
if (spec.length() == 0) return; // Skip empty specs
if (spec.startsWith("file:")) {
final LineIterator lineIterator = new LineIterator(new FastBufferedReader(new InputStreamReader(new FileInputStream(spec.substring(5)), Charsets.ISO_8859_1)));
while (lineIterator.hasNext()) {
final MutableString line = lineIterator.next();
if (line.length() > 0) blackListedIPv4Addresses.add(handleIPv4(line.toString()));
}
}
else blackListedIPv4Addresses.add(handleIPv4(spec));
}
示例3: addBlackListedHost
/** Adds a (or a set of) new host to the black list; the host can be specified directly or it can be a file (prefixed by
* <code>file:</code>).
*
* @param spec the specification (a host, or a file prefixed by <code>file</code>).
* @throws ConfigurationException
* @throws FileNotFoundException
*/
public void addBlackListedHost(final String spec) throws ConfigurationException, FileNotFoundException {
if (spec.length() == 0) return; // Skip empty specs
if (spec.startsWith("file:")) {
final LineIterator lineIterator = new LineIterator(new FastBufferedReader(new InputStreamReader(new FileInputStream(spec.substring(5)), Charsets.ISO_8859_1)));
while (lineIterator.hasNext()) {
final MutableString line = lineIterator.next();
blackListedHostHashes.add(line.toString().trim().hashCode());
}
}
else blackListedHostHashes.add(spec.trim().hashCode());
}
示例4: hostWithStartEnd
public static String hostWithStartEnd(byte[] url) {
final int startOfHost = BURL.startOfHost(url);
final int lengthOfHost = BURL.lengthOfHost(url, startOfHost);
return new String(url, startOfHost, lengthOfHost, Charsets.ISO_8859_1);
}
示例5: toString
/**
* A string representation of this job
*
* @return the URI of this job in string format
*/
@Override
public String toString() {
return "[" + new String(url.elements(), 0, url.size(), Charsets.ISO_8859_1) + "]";
}