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


Java FileObject.openReader方法代码示例

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


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

示例1: convertClass

import javax.tools.FileObject; //导入方法依赖的package包/类
/**
 * Convert the given Class to an HTML.
 *
 * @param te the class to convert.
 * @param outputdir the name of the directory to output to
 * @throws DocFileIOException if there is a problem generating the output file
 * @throws SimpleDocletException if there is a problem reading the source file
 */
public void convertClass(TypeElement te, DocPath outputdir)
        throws DocFileIOException, SimpleDocletException {
    if (te == null) {
        return;
    }
    FileObject fo = utils.getFileObject(te);
    if (fo == null)
        return;

    try {
        Reader r = fo.openReader(true);
        int lineno = 1;
        String line;
        relativePath = DocPaths.SOURCE_OUTPUT
                .resolve(DocPath.forPackage(utils, te))
                .invert();
        Content body = getHeader();
        Content pre = new HtmlTree(HtmlTag.PRE);
        try (LineNumberReader reader = new LineNumberReader(r)) {
            while ((line = reader.readLine()) != null) {
                addLineNo(pre, lineno);
                addLine(pre, line, lineno);
                lineno++;
            }
        }
        addBlankLines(pre);
        Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
        body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(div) : div);
        writeToFile(body, outputdir.resolve(DocPath.forClass(utils, te)));
    } catch (IOException e) {
        String message = configuration.resources.getText("doclet.exception.read.file", fo.getName());
        throw new SimpleDocletException(message, e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:SourceToHTMLConverter.java

示例2: SimpleResourceReader

import javax.tools.FileObject; //导入方法依赖的package包/类
public SimpleResourceReader(FileObject fileObject) throws IOException {
    this.fileObject = fileObject;
    this.foReader = new BufferedReader(fileObject.openReader(true));
}
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:5,代码来源:SimpleResourceReader.java

示例3: convertClass

import javax.tools.FileObject; //导入方法依赖的package包/类
/**
 * Convert the given Class to an HTML.
 *
 * @param cd the class to convert.
 * @param outputdir the name of the directory to output to.
 */
public void convertClass(ClassDoc cd, DocPath outputdir) {
    if (cd == null) {
        return;
    }
    try {
        SourcePosition sp = cd.position();
        if (sp == null)
            return;
        Reader r;
        // temp hack until we can update SourcePosition API.
        if (sp instanceof com.sun.tools.javadoc.SourcePositionImpl) {
            FileObject fo = ((com.sun.tools.javadoc.SourcePositionImpl) sp).fileObject();
            if (fo == null)
                return;
            r = fo.openReader(true);
        } else {
            File file = sp.file();
            if (file == null)
                return;
            r = new FileReader(file);
        }
        LineNumberReader reader = new LineNumberReader(r);
        int lineno = 1;
        String line;
        relativePath = DocPaths.SOURCE_OUTPUT
                .resolve(DocPath.forPackage(cd))
                .invert();
        Content body = getHeader();
        Content pre = new HtmlTree(HtmlTag.PRE);
        try {
            while ((line = reader.readLine()) != null) {
                addLineNo(pre, lineno);
                addLine(pre, line, lineno);
                lineno++;
            }
        } finally {
            reader.close();
        }
        addBlankLines(pre);
        Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
        body.addContent(div);
        writeToFile(body, outputdir.resolve(DocPath.forClass(cd)));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:SourceToHTMLConverter.java


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