本文整理汇总了Java中org.marc4j.MarcReader.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java MarcReader.hasNext方法的具体用法?Java MarcReader.hasNext怎么用?Java MarcReader.hasNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.marc4j.MarcReader
的用法示例。
在下文中一共展示了MarcReader.hasNext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readMARCRecords
import org.marc4j.MarcReader; //导入方法依赖的package包/类
private Sequence readMARCRecords(final MarcReader aReader) throws XPathException {
final MemTreeBuilder builder = context.getDocumentBuilder();
final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder);
final SAXResult saxResult = new SAXResult(receiver);
final MarcWriter writer = new MarcXmlWriter(saxResult);
writer.setConverter(new AnselToUnicode());
while (aReader.hasNext()) {
final Record record = aReader.next();
final String recordId = record.getControlNumber();
if (LOGGER.isDebugEnabled() && recordId != null) {
LOGGER.debug("Reading MARC record: " + recordId);
}
writer.write(record);
}
writer.close();
return (DocumentImpl) receiver.getDocument();
}
示例2: read
import org.marc4j.MarcReader; //导入方法依赖的package包/类
public static List<Record> read(String fileName) throws Exception {
InputStream in = new FileInputStream(fileName);
MarcReader reader = new MarcStreamReader(in);
List<Record> records = new ArrayList<>();
while (reader.hasNext()) {
Record marc4jRecord = reader.next();
records.add(marc4jRecord);
// System.out.println(record.toString());
}
return records;
}
示例3: toMarcXml
import org.marc4j.MarcReader; //导入方法依赖的package包/类
/** Converts Marc21 to MarcXML */
public static Document toMarcXml(byte[] marc21, String charset) {
MarcReader reader = new MarcStreamReader(new ByteArrayInputStream(marc21), charset);
DOMResult result = new DOMResult();
MarcXmlWriter writer = new MarcXmlWriter(result);
if (reader.hasNext()) {
Record record = reader.next();
writer.write(record);
}
writer.close();
Document retval = (Document) result.getNode();
return retval;
}
示例4: convertRawMarcToXML
import org.marc4j.MarcReader; //导入方法依赖的package包/类
/**
* @param inputFile
* @return converted marc xml File Name
* @throws java.io.FileNotFoundException This method takes in a raw marc file and converts into a marc xml file.
*/
public String convertRawMarcToXML(File inputFile) throws FileNotFoundException {
InputStream input = new FileInputStream(inputFile);
String fileName = inputFile.getName().replace(".mrc", ".xml");
FileOutputStream fileOutputStream = new FileOutputStream(new File(fileName));
MarcReader reader = new MarcStreamReader(input);
MarcWriter writer = new MarcXmlWriter(fileOutputStream, true);
while (reader.hasNext()) {
Record record = reader.next();
writer.write(record);
}
writer.close();
return fileName;
}
示例5: convert
import org.marc4j.MarcReader; //导入方法依赖的package包/类
/**
* @param content
* @return converted marc xml
*/
public String convert(String content) {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content.getBytes());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
MarcReader reader = new MarcStreamReader(byteArrayInputStream);
MarcWriter writer = new MarcXmlWriter(byteArrayOutputStream, true);
while (reader.hasNext()) {
Record record = reader.next();
writer.write(record);
}
writer.close();
return new String(byteArrayOutputStream.toByteArray());
}
示例6: next
import org.marc4j.MarcReader; //导入方法依赖的package包/类
@Override
public Record next() {
InputStream is = new ByteArrayInputStream(line.getBytes());
MarcReader reader = new MarcStreamReader(is);
Record marc4jRecord = null;
if (reader.hasNext()) {
marc4jRecord = reader.next();
}
nextIsConsumed = true;
return marc4jRecord;
}