java.util.Formatter#ioException ( )源码实例Demo

下面列出了java.util.Formatter#ioException ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: rapidminer-studio   文件: Linear.java
static void printf(Formatter formatter, String format, Object... args) throws IOException {
	formatter.format(format, args);
	IOException ioException = formatter.ioException();
	if (ioException != null) {
		throw ioException;
	}
}
 
源代码2 项目: MMDW   文件: Linear.java
static void printf(Formatter formatter, String format, Object... args) throws IOException {
    formatter.format(format, args);
    IOException ioException = formatter.ioException();
    if (ioException != null) throw ioException;
}
 
源代码3 项目: MMDW   文件: Linear.java
/**
 * 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();
    }
}
 
源代码4 项目: rapidminer-studio   文件: Linear.java
/**
 * 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();
	}
}
 
源代码5 项目: ml-ease   文件: Linear.java
static void printf(Formatter formatter, String format, Object... args) throws IOException {
    formatter.format(format, args);
    IOException ioException = formatter.ioException();
    if (ioException != null) throw ioException;
}
 
源代码6 项目: ml-ease   文件: Linear.java
/**
 * 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);

        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();
    }
}