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


Java Util.closeSilently方法代码示例

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


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

示例1: handleXArgs

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
/**
 * Handle -xargs command line option by reading jar file names from standard
 * input and adding them to the project.
 *
 * @throws IOException
 */
public void handleXArgs() throws IOException {
    if (getXargs()) {
        BufferedReader in = UTF8.bufferedReader(System.in);
        try {
        while (true) {
            String s = in.readLine();
            if (s == null)
                break;
            project.addFile(s);
        }
        } finally {
         Util.closeSilently(in);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:TextUICommandLine.java

示例2: checkAuthorized

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
private boolean checkAuthorized(URL response) throws IOException {
    HttpURLConnection connection = (HttpURLConnection) response.openConnection();

    int responseCode = connection.getResponseCode();
    if (responseCode == 200) {
        InputStream in = connection.getInputStream();
        BufferedReader reader = UTF8.bufferedReader(in);
        try {
            String status = reader.readLine();
            sessionId = Long.parseLong(reader.readLine());
            username = reader.readLine();
            Util.closeSilently(reader);
            if ("OK".equals(status)) {
                LOGGER.info("Authorized session " + sessionId);
                return true;
            }
        } finally {
            reader.close();
        }

    }
    connection.disconnect();
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:WebCloudNameLookup.java

示例3: getAnalysisOptionProperties

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
public static ArrayList<String> getAnalysisOptionProperties(boolean ignoreComments, boolean ignoreBlankLines) {
    ArrayList<String> resultList = new ArrayList<String>();
    URL u = DetectorFactoryCollection.getCoreResource("analysisOptions.properties");
    if (u != null) {
        BufferedReader reader = null;
        try {
            reader = UTF8.bufferedReader(u.openStream());
            addCommandLineOptions(resultList, reader, ignoreComments, ignoreBlankLines);
        } catch (IOException e) {
            AnalysisContext.logError("unable to load analysisOptions.properties", e);
        } finally {
            Util.closeSilently(reader);
        }
    }
    return resultList;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:17,代码来源:CommandLine.java

示例4: verifyURL

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
public static boolean verifyURL(URL u) {
    if (u == null)
        return false;

    InputStream i = null;

    try {
        URLConnection uc = u.openConnection();
        i = uc.getInputStream();
        int firstByte = i.read();
        i.close();
        return firstByte >= 0;
    }

    catch (Exception e) {
        return false;
    } finally {
        Util.closeSilently(i);
    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:IO.java

示例5: ProjectPackagePrefixes

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
public ProjectPackagePrefixes() {
    URL u = DetectorFactoryCollection.getCoreResource("projectPaths.properties");
    if (u != null) {

        BufferedReader in = null;
        try {
             in = UTF8.bufferedReader(u.openStream());
            while (true) {
                String s = in.readLine();
                if (s == null)
                    break;
                String[] parts = s.split("=");
                if (parts.length == 2 && !map.containsKey(parts[0]))
                    map.put(parts[0], new PrefixFilter(parts[1]));
            }
        } catch (IOException e1) {

            AnalysisContext.logError("Error loading projects paths", e1);
        } finally {
           Util.closeSilently(in);
        }

    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:ProjectPackagePrefixes.java

示例6: parseUpdateXml

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked" })
    void parseUpdateXml(URI url, Collection<Plugin> plugins, @WillClose
    InputStream inputStream) {
        try {
            Document doc = new SAXReader().read(inputStream);
//            StringWriter stringWriter = new StringWriter();
//            XMLWriter xmlWriter = new XMLWriter(stringWriter);
//            xmlWriter.write(doc);
//            xmlWriter.close();
//            System.out.println("UPDATE RESPONSE: " + stringWriter.toString());
            List<Element> pluginEls =  XMLUtil.selectNodes(doc, "fb-plugin-updates/plugin");
            Map<String, Plugin> map = new HashMap<String, Plugin>();
            for (Plugin p : plugins)
                map.put(p.getPluginId(), p);
            for (Element pluginEl : pluginEls) {
                String id = pluginEl.attributeValue("id");
                Plugin plugin = map.get(id);
                if (plugin != null) {
                    checkPlugin(pluginEl, plugin);
                }

            }
        } catch (Exception e) {
            logError(e, "Could not parse plugin version update for " + url);
        } finally {
            Util.closeSilently(inputStream);
        }
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:29,代码来源:UpdateChecker.java

示例7: parseDocument

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
private static Document parseDocument(@WillClose InputStream in) throws DocumentException {
    Reader r = UTF8.bufferedReader(in);
    try {
        SAXReader reader = new SAXReader();
        Document d = reader.read(r);
        return d;
    } finally {
        Util.closeSilently(r);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:11,代码来源:PluginLoader.java

示例8: InMemorySourceRepository

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
InMemorySourceRepository(@WillClose ZipInputStream in) throws IOException {
    try {
        while (true) {

            ZipEntry e = in.getNextEntry();
            if (e == null)
                break;
            if (!e.isDirectory()) {
                String name = e.getName();
                long size = e.getSize();

                if (size > Integer.MAX_VALUE)
                    throw new IOException(name + " is too big at " + size + " bytes");
                ByteArrayOutputStream out;
                if (size <= 0)
                    out = new ByteArrayOutputStream();
                else
                    out = new ByteArrayOutputStream((int) size);
                GZIPOutputStream gOut = new GZIPOutputStream(out);
                IO.copy(in, gOut);
                gOut.close();
                byte data[] = out.toByteArray();
                contents.put(name, data);
                lastModified.put(name, e.getTime());
            }
            in.closeEntry();
        }
    } finally {
        Util.closeSilently(in);
    }

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

示例9: BugRanker

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
/**
 * @param u
 *            may be null. In this case, a default value will be used for
 *            all bugs
 * @throws IOException
 */
BugRanker(@CheckForNull URL u) throws IOException {
    if (u == null) {
        return;
    }
    BufferedReader in = UTF8.bufferedReader(u.openStream());
    try {
        while (true) {
            String s = in.readLine();
            if (s == null)
                break;

            s = s.trim();
            if (s.length() == 0)
                continue;

            String parts[] = s.split(" ");
            String rank = parts[0];
            String kind = parts[1];
            String what = parts[2];
            if (kind.equals("BugPattern"))
                bugPatterns.storeAdjustment(what, rank);
            else if (kind.equals("BugKind"))
                bugKinds.storeAdjustment(what, rank);
            else if (kind.equals("Category"))
                bugCategories.storeAdjustment(what, rank);
            else
                AnalysisContext.logError("Can't parse bug rank " + s);
        }
    } finally {
        Util.closeSilently(in);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:39,代码来源:BugRanker.java

示例10: expandOptionFiles

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
/**
 * Expand option files in given command line. Any token beginning with "@"
 * is assumed to be an option file. Option files contain one command line
 * option per line.
 *
 * @param argv
 *            the original command line
 * @param ignoreComments
 *            ignore comments (lines starting with "#")
 * @param ignoreBlankLines
 *            ignore blank lines
 * @return the expanded command line
 */

public String[] expandOptionFiles(String[] argv, boolean ignoreComments, boolean ignoreBlankLines) throws IOException,
        HelpRequestedException {
    // Add all expanded options at the end of the options list, before the
    // list of
    // jar/zip/class files and directories.
    // At the end of the options to preserve the order of the options (e.g.
    // -adjustPriority
    // must always come after -pluginList).
    int lastOptionIndex = parse(argv, true);
    ArrayList<String> resultList = new ArrayList<String>();
    ArrayList<String> expandedOptionsList = getAnalysisOptionProperties(ignoreComments, ignoreBlankLines);
    for (int i = 0; i < lastOptionIndex; i++) {
        String arg = argv[i];
        if (!arg.startsWith("@")) {
            resultList.add(arg);
            continue;
        }

        BufferedReader reader = null;
        try {
            reader = UTF8.bufferedReader(new FileInputStream(arg.substring(1)));
            addCommandLineOptions(expandedOptionsList, reader, ignoreComments, ignoreBlankLines);
        } finally {
            Util.closeSilently(reader);
        }
    }
    resultList.addAll(expandedOptionsList);
    for (int i = lastOptionIndex; i < argv.length; i++) {
        resultList.add(argv[i]);
    }

    return resultList.toArray(new String[resultList.size()]);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:48,代码来源:CommandLine.java

示例11: parseUpdateXml

import edu.umd.cs.findbugs.util.Util; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked" })
void parseUpdateXml(URI url, Collection<Plugin> plugins, @WillClose
InputStream inputStream) {
    try {
        Document doc = new SAXReader().read(inputStream);
        if (DEBUG) {
            StringWriter stringWriter = new StringWriter();
            XMLWriter xmlWriter = new XMLWriter(stringWriter);
            xmlWriter.write(doc);
            xmlWriter.close();
            System.out.println("UPDATE RESPONSE: " + stringWriter.toString());
        }
        List<Element> pluginEls =  XMLUtil.selectNodes(doc, "fb-plugin-updates/plugin");
        Map<String, Plugin> map = new HashMap<String, Plugin>();
        for (Plugin p : plugins)
            map.put(p.getPluginId(), p);
        for (Element pluginEl : pluginEls) {
            String id = pluginEl.attributeValue("id");
            Plugin plugin = map.get(id);
            if (plugin != null) {
                checkPlugin(pluginEl, plugin);
            }

        }
    } catch (Exception e) {
        logError(e, "Could not parse plugin version update for " + url);
    } finally {
        Util.closeSilently(inputStream);
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:31,代码来源:UpdateChecker.java


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