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


Java Util.getReader方法代码示例

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


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

示例1: readXML

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
public static Project readXML(File f) throws IOException,  SAXException {
    InputStream in = new BufferedInputStream(new FileInputStream(f));
    Project project = new Project();
    try {
        String tag = Util.getXMLType(in);
        SAXBugCollectionHandler handler;
        if (tag.equals("Project")) {
            handler = new SAXBugCollectionHandler(project, f);
        } else if (tag.equals("BugCollection")) {
            SortedBugCollection bugs = new SortedBugCollection(project);
            handler = new SAXBugCollectionHandler(bugs, f);
        } else {
            throw new IOException("Can't load a project from a " + tag + " file");
        }

        XMLReader xr = XMLReaderFactory.createXMLReader();

        xr.setContentHandler(handler);
        xr.setErrorHandler(handler);

        Reader reader = Util.getReader(in);

        xr.parse(new InputSource(reader));
    } finally {
        in.close();
    }

    // Presumably, project is now up-to-date
    project.setModified(false);

    return project;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:33,代码来源:Project.java

示例2: read

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
/**
 * Read property database from an input stream. The InputStream is
 * guaranteed to be closed, even if an exception is thrown.
 *
 * @param in
 *            the InputStream
 * @throws IOException
 * @throws MethodPropertyDatabaseFormatException
 */
public void read(@WillClose InputStream in) throws IOException, PropertyDatabaseFormatException {
    BufferedReader reader = null;

    try {
        reader = new BufferedReader(Util.getReader(in));
        String line;
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            if (line.equals(""))
                continue;
            int bar = line.indexOf('|');
            if (bar < 0) {
                throw new PropertyDatabaseFormatException("Invalid property database: missing separator");
            }
            KeyType key = parseKey(line.substring(0, bar));
            ValueType property = decodeProperty(line.substring(bar + 1));

            setProperty(key, property);
        }
    } finally {
        try {
            if (reader != null)
                reader.close();
        } catch (IOException e) {
            // Ignore
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:38,代码来源:PropertyDatabase.java

示例3: checkInputStream

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
private static void checkInputStream(@WillNotClose InputStream in) throws IOException {
    if (!in.markSupported())
        return;

    byte[] buf = new byte[200];
    in.mark(buf.length);

    int numRead = 0;

    boolean isEOF = false;
    while (numRead < buf.length && !isEOF) {
        int n = in.read(buf, numRead, buf.length - numRead);
        if (n < 0) {
            isEOF = true;
        } else {
            numRead += n;
        }
    }

    in.reset();

    BufferedReader reader = new BufferedReader(Util.getReader(new ByteArrayInputStream(buf)));
    try {
        String line;
        while ((line = reader.readLine()) != null) {
            if (line.startsWith("<BugCollection")) {
                return;
            }
        }
    } finally {
        reader.close();
    }

    throw new IOException("XML does not contain saved bug data");
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:36,代码来源:SortedBugCollection.java

示例4: process

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
/**
 * @param inSource
 * @throws UnsupportedEncodingException
 * @throws IOException
 */
private static void process(@WillClose InputStream inSource) throws UnsupportedEncodingException, IOException {
    BufferedReader in = null;
    try {
        in = new BufferedReader(Util.getReader(inSource));

        Pattern p = Pattern.compile("^(([^,]+),.+),([0-9]+)\\|(.+)$");
        
        while (true) {
            String s = in.readLine();
            if (s == null)
                break;
            Matcher m = p.matcher(s);
            if (m.find()) {
                String className = m.group(2);
                if (FilterAndCombineBitfieldPropertyDatabase.getStatus(className) == Status.UNEXPOSED)
                    continue;
                int accFlags = Integer.parseInt(m.group(3));
               
                if ((accFlags & FLAGS) != 0)
                    System.out.println(s);
            }

        }
    } finally {
        Util.closeSilently(in);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:33,代码来源:FilterPropertyDatabase.java

示例5: process

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
/**
 * @param inSource
 * @throws UnsupportedEncodingException
 * @throws IOException
 */
private static void process(@WillClose InputStream inSource, Map<String, Integer> properties, Map<String, Integer> accessFlags)
        throws UnsupportedEncodingException, IOException {
    BufferedReader in = new BufferedReader(Util.getReader(inSource));
    Pattern p = Pattern.compile("^(([^,]+),.+),([0-9]+)\\|([0-9]+)$");
    try {
        while (true) {
            String s = in.readLine();
            if (s == null)
                break;
            Matcher m = p.matcher(s);
            if (m.find()) {
                String key = m.group(1);
                String className = m.group(2);
                if (getStatus(className) == Status.UNEXPOSED)
                    continue;
                int accFlags = Integer.parseInt(m.group(3));
                int bits = Integer.parseInt(m.group(4));
                if ((accFlags & FLAGS) != 0) {
                    accessFlags.put(key, accFlags);
                    if (properties.containsKey(key))
                        properties.put(key, bits | properties.get(key));
                    else
                        properties.put(key, bits);
                }
            }

        }
    } finally {
        Util.closeSilently(in);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:37,代码来源:FilterAndCombineBitfieldPropertyDatabase.java

示例6: processPage

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
/**
 * Process an HTML page to replace certain substitution patterns.
 * Right now, we just expand @[email protected]
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings("OS_OPEN_STREAM")
private void processPage(javax.swing.JEditorPane pane, String fileName) throws IOException {
    InputStream in = null;
    BufferedReader reader = null;
    try {
        StringBuilder buf = new StringBuilder();

        // Open the file as a stream
        in = getClass().getClassLoader().getResourceAsStream(fileName);
        if (in == null)
            throw new IOException(MessageFormat.format(L10N.getLocalString("msg.couldntload_txt", "Couldn't load {0}"), new Object[]{fileName}));
         reader = new BufferedReader(Util.getReader(in));

        // Replace instances of @[email protected] with actual version number

        String line;
        while ((line = reader.readLine()) != null) {
            line = pattern.matcher(line).replaceAll(Version.RELEASE);
            buf.append(line);
            buf.append('\n');
        }

        // Load the page into the editor pane
        String text = buf.toString();
        pane.setContentType("text/html");
        pane.setText(text);
    } finally {
        try {
            if (reader != null)
                reader.close();
            else if (in != null)
                in.close();
        } catch (IOException e) {
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:41,代码来源:AboutDialog.java

示例7: read

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
/**
 * Read property database from an input stream. The InputStream is
 * guaranteed to be closed, even if an exception is thrown.
 *
 * @param in
 *            the InputStream
 * @throws IOException
 * @throws PropertyDatabaseFormatException
 */
public void read(@WillClose InputStream in) throws IOException, PropertyDatabaseFormatException {
    BufferedReader reader = null;

    try {
        reader = new BufferedReader(Util.getReader(in));
        String line;
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            if (line.equals(""))
                continue;
            int bar = line.indexOf('|');
            if (bar < 0) {
                throw new PropertyDatabaseFormatException("Invalid property database: missing separator");
            }
            KeyType key = parseKey(line.substring(0, bar));
            ValueType property = decodeProperty(line.substring(bar + 1));

            setProperty(key, property);
        }
    } finally {
        try {
            if (reader != null)
                reader.close();
        } catch (IOException e) {
            // Ignore
        }
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:38,代码来源:PropertyDatabase.java


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