当前位置: 首页>>代码示例>>Java>>正文


Java IOException.fillInStackTrace方法代码示例

本文整理汇总了Java中java.io.IOException.fillInStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java IOException.fillInStackTrace方法的具体用法?Java IOException.fillInStackTrace怎么用?Java IOException.fillInStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.IOException的用法示例。


在下文中一共展示了IOException.fillInStackTrace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHeader

import java.io.IOException; //导入方法依赖的package包/类
public static String[] getHeader( String fileName) throws IOException {
	//String file1 = fileName;
	NetcdfFile ncFile = null;
	String[] attributeNetCDF;
	try {
		ncFile = NetcdfFile.open(fileName);
	} catch(java.lang.IllegalArgumentException ex) {
		IOException e = new IOException("Not a netcdf file");
		e.fillInStackTrace();
		throw e;
	}
	List<?> globalAttList = ncFile.getGlobalAttributes();
	attributeNetCDF = new String[globalAttList.size()];

	for(int i=0; i < globalAttList.size(); i++ ) {
		attributeNetCDF[i] = globalAttList.get(i).toString();
	}
	return attributeNetCDF;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:20,代码来源:GrdProperties.java

示例2: generateCode

import java.io.IOException; //导入方法依赖的package包/类
private void generateCode(Map<String, List<Element>> targetInjectElements) throws ProcessException {
    if (targetInjectElements == null || targetInjectElements.isEmpty()) {
        return;
    }

    for (Map.Entry<String, List<Element>> entry : targetInjectElements.entrySet()) {
        String targetFullClzName = entry.getKey();
        List<Element> injectElements = entry.getValue();
        if (injectElements == null || injectElements.isEmpty()) {
            continue;
        }

        // 创建注入方法
        TypeElement target = mElementUtils.getTypeElement(targetFullClzName);
        ParameterSpec injectParameter = ParameterSpec.builder(ClassName.get(target), Constants.PARAMETER_OF_TARGET).build();
        MethodSpec.Builder injectMethod = MethodSpec.methodBuilder(Constants.METHOD_OF_INJECT)
                .addJavadoc("向{@code $N}注入组件\[email protected] $N",
                        Constants.PARAMETER_OF_TARGET,
                        Constants.PARAMETER_OF_TARGET)
                .addModifiers(Modifier.PUBLIC, Modifier.STATIC)
                .addParameter(injectParameter)
                .returns(void.class);
        for (Element injectElement : injectElements) {
            injectMethod
                    .beginControlFlow("try")
                    .addStatement("$N.$N = ($T) $T.getInstance().getModule($S)",
                            Constants.PARAMETER_OF_TARGET,
                            injectElement.getSimpleName(),
                            injectElement.asType(),
                            mElementUtils.getTypeElement(Constants.XMODULABLE),
                            injectElement.getAnnotation(InjectXModule.class).name())
                    .nextControlFlow("catch ($T e)",
                            ClassName.get(mElementUtils.getTypeElement(Constants.UNKNOWN_MODULE_EXCEPTION)))
                    .addStatement("e.printStackTrace()")
                    .endControlFlow();
        }
        mLogger.info(String.format("创建方法:%s", Constants.METHOD_OF_INJECT));

        // 创建类
        String injectorClzName = new StringBuilder()
                .append(target.getSimpleName())
                .append(Constants.SEPARATOR_OF_CLASS_NAME)
                .append(Constants.CLASS_OF_INJECTOR)
                .toString();
        TypeSpec.Builder targetInjector = TypeSpec.classBuilder(injectorClzName)
                .addJavadoc(
                        new StringBuilder()
                                .append("组件注入器")
                                .append("\n")
                                .append("<ul><li>")
                                .append(Constants.WARNING_TIPS)
                                .append("</li></ul>")
                                .append("\[email protected] $N")
                                .toString(),
                        InjectProcessor.class.getSimpleName())
                .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
                .addMethod(injectMethod.build());
        mLogger.info(String.format("创建类:%s", injectorClzName));

        // 输出源文件
        try {
            String pkgName = mElementUtils.getPackageOf(injectElements.get(0)).getQualifiedName().toString();
            JavaFile.builder(pkgName, targetInjector.build())
                    .build()
                    .writeTo(mFiler);
            mLogger.info(String.format("输出源文件:%s", pkgName + "." + injectorClzName + ".java"));
        } catch (IOException e) {
            throw new ProcessException(e.fillInStackTrace());
        }
    }
}
 
开发者ID:xpleemoon,项目名称:XModulable,代码行数:72,代码来源:InjectProcessor.java

示例3: generateCode

import java.io.IOException; //导入方法依赖的package包/类
/**
 * 生成源码,主要由三个步骤
 * <ol>
 * <li>创建方法</li>
 * <li>创建类</li>
 * <li>输出源文件</li>
 * </ol>
 *
 * @param moduleElements key:组件名;value:携带@XModule的Element
 */
private void generateCode(Map<String, Element> moduleElements) throws ProcessException {
    if (moduleElements == null || moduleElements.isEmpty()) {
        return;
    }

    /*
    1、创建方法
    public void loadInto(XModulableOptions options) {
           if (options == null) {
               return;
           }
           options.addModule(, );
     }
     */
    MethodSpec.Builder loadIntoMethod = MethodSpec.methodBuilder(Constants.METHOD_OF_LOAD_INTO)
            .addJavadoc("向$N添加组件", Constants.PARAMETER_OF_XMODULABLE_OPTIONS)
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .addParameter(ClassName.get(mElementUtils.getTypeElement(Constants.XMODULABLE_OPTIONS)), Constants.PARAMETER_OF_XMODULABLE_OPTIONS)
            .returns(void.class)
            .beginControlFlow("if ($N == null)", Constants.PARAMETER_OF_XMODULABLE_OPTIONS)
            .addStatement("return")
            .endControlFlow();
    for (Map.Entry<String, Element> entry : moduleElements.entrySet()) {
        String moduleName = entry.getKey();
        TypeName moduleTypeName = TypeName.get(entry.getValue().asType()); // 注解的宿主类型名
        loadIntoMethod.addStatement("$N.addModule($S, new $T())", Constants.PARAMETER_OF_XMODULABLE_OPTIONS, moduleName, moduleTypeName);
    }
    mLogger.info(String.format("创建方法:%s", Constants.METHOD_OF_LOAD_INTO));

    /*
    2、创建类
    public final class XModule$$Loader$$组件名 implements XModuleLoader
     */
    String className = new StringBuilder()
            .append(Constants.SDK_NAME)
            .append(Constants.SEPARATOR_OF_CLASS_NAME)
            .append(Constants.CLASS_OF_LOADER)
            .append(Constants.SEPARATOR_OF_CLASS_NAME)
            .append(mModuleName)
            .toString();
    TypeSpec.Builder componentLoader = TypeSpec.classBuilder(className)
            .addJavadoc(
                    new StringBuilder()
                            .append("$N组件加载器")
                            .append("\n")
                            .append("<ul><li>")
                            .append(Constants.WARNING_TIPS)
                            .append("</li></ul>")
                            .append("\[email protected] $N")
                            .toString(),
                    mModuleName,
                    XModuleProcessor.class.getSimpleName())
            .addSuperinterface(ClassName.get(mXModuleLoader))
            .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
            .addMethod(loadIntoMethod.build());
    mLogger.info(String.format("创建类:%s", className));

    /*
    3、输出源文件
    XModule$$Loader$$组件名.java
     */
    try {
        JavaFile.builder(Constants.PACKAGE_OF_GENERATE, componentLoader.build())
                .build().writeTo(mFiler);
        mLogger.info(String.format("输出源文件:%s", Constants.PACKAGE_OF_GENERATE + "." + className + ".java"));
    } catch (IOException e) {
        throw new ProcessException(e.fillInStackTrace());
    }
}
 
开发者ID:xpleemoon,项目名称:XModulable,代码行数:81,代码来源:XModuleProcessor.java


注:本文中的java.io.IOException.fillInStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。