當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。