本文整理汇总了Java中org.jbibtex.BibTeXParser类的典型用法代码示例。如果您正苦于以下问题:Java BibTeXParser类的具体用法?Java BibTeXParser怎么用?Java BibTeXParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BibTeXParser类属于org.jbibtex包,在下文中一共展示了BibTeXParser类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.jbibtex.BibTeXParser; //导入依赖的package包/类
/**
* Helper tool to convert bibtex to {@link Reference} annotations. Reads
* from stdin, writes to stdout.
*
* @param args
* not used
* @throws IOException
* @throws ParseException
*/
public static void main(String[] args) throws IOException, ParseException {
System.out.println("Enter bibtex record(s), followed by ctrl-d: ");
final Reader reader = new InputStreamReader(System.in);
final BibTeXParser parser = new BibTeXParser();
final BibTeXDatabase database = parser.parse(reader);
System.out.println();
for (final BibTeXEntry entry : database.getEntries().values()) {
final Reference r = MockReference.makeReference(entry);
System.out.println(StandardFormatters.REFERENCE_ANNOTATION.format(r));
}
}
示例2: loadDatabase
import org.jbibtex.BibTeXParser; //导入依赖的package包/类
/**
* <p>Loads a BibTeX database from a stream.</p>
* <p>This method does not close the given stream. The caller is
* responsible for closing it.</p>
* @param is the input stream to read from
* @return the BibTeX database
* @throws IOException if the database could not be read
* @throws ParseException if the database is invalid
*/
public BibTeXDatabase loadDatabase(InputStream is) throws IOException, ParseException {
Reader reader = new InputStreamReader(is, "UTF-8");
BibTeXParser parser = new BibTeXParser() {
@Override
public void checkStringResolution(Key key, BibTeXString string) {
if (string == null) {
//ignore
}
}
};
try {
return parser.parse(reader);
} catch (TokenMgrException err) {
throw new ParseException("Could not parse BibTeX library: " +
err.getMessage());
}
}