本文整理汇总了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;
}
示例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
}
}
}
示例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");
}
示例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);
}
}
示例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);
}
}
示例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) {
}
}
}
示例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
}
}
}