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


Java Formatter.ioException方法代碼示例

本文整理匯總了Java中java.util.Formatter.ioException方法的典型用法代碼示例。如果您正苦於以下問題:Java Formatter.ioException方法的具體用法?Java Formatter.ioException怎麽用?Java Formatter.ioException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Formatter的用法示例。


在下文中一共展示了Formatter.ioException方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: printf

import java.util.Formatter; //導入方法依賴的package包/類
static void printf(Formatter formatter, String format, Object... args) throws IOException {
	formatter.format(format, args);
	IOException ioException = formatter.ioException();
	if (ioException != null) {
		throw ioException;
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:8,代碼來源:Linear.java

示例2: saveModel

import java.util.Formatter; //導入方法依賴的package包/類
/**
 * Writes the model to the modelOutput. It uses {@link java.util.Locale#ENGLISH} for number
 * formatting.
 *
 * <p>
 * <b>Note: The modelOutput is closed after reading or in case of an exception.</b>
 * </p>
 */
public static void saveModel(Writer modelOutput, Model model) throws IOException {
	int nr_feature = model.nr_feature;
	int w_size = nr_feature;
	if (model.bias >= 0) {
		w_size++;
	}

	int nr_w = model.nr_class;
	if (model.nr_class == 2 && model.solverType != SolverType.MCSVM_CS) {
		nr_w = 1;
	}

	Formatter formatter = new Formatter(modelOutput, DEFAULT_LOCALE);
	try {
		printf(formatter, "solver_type %s\n", model.solverType.name());
		printf(formatter, "nr_class %d\n", model.nr_class);

		if (model.label != null) {
			printf(formatter, "label");
			for (int i = 0; i < model.nr_class; i++) {
				printf(formatter, " %d", model.label[i]);
			}
			printf(formatter, "\n");
		}

		printf(formatter, "nr_feature %d\n", nr_feature);
		printf(formatter, "bias %.16g\n", model.bias);

		printf(formatter, "w\n");
		for (int i = 0; i < w_size; i++) {
			for (int j = 0; j < nr_w; j++) {
				double value = model.w[i * nr_w + j];

				/** this optimization is the reason for {@link Model#equals(double[], double[])} */
				if (value == 0.0) {
					printf(formatter, "%d ", 0);
				} else {
					printf(formatter, "%.16g ", value);
				}
			}
			printf(formatter, "\n");
		}

		formatter.flush();
		IOException ioException = formatter.ioException();
		if (ioException != null) {
			throw ioException;
		}
	} finally {
		formatter.close();
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:61,代碼來源:Linear.java


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