本文整理匯總了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) + "]";
}