当前位置: 首页>>代码示例>>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;未经允许,请勿转载。