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


Java Charsets.ISO_8859_1屬性代碼示例

本文整理匯總了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();
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:31,代碼來源:AvdManager.java

示例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));
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:18,代碼來源:RuntimeConfiguration.java

示例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());
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:18,代碼來源:RuntimeConfiguration.java

示例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);
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:5,代碼來源:BURLTest.java

示例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) + "]";
 }
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:9,代碼來源:BubingJob.java


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