
de.gwdg.metadataqa.marc.utils.ReadMarc Maven / Gradle / Ivy
package de.gwdg.metadataqa.marc.utils;
import org.marc4j.MarcReader;
import org.marc4j.MarcStreamReader;
import org.marc4j.marc.Record;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class ReadMarc {
public static List read(String fileName) throws Exception {
return read(fileName, null);
}
public static List read(String fileName, String encoding) throws Exception {
InputStream in = new FileInputStream(fileName);
MarcReader reader = new MarcStreamReader(in, encoding);
List records = new ArrayList<>();
while (reader.hasNext()) {
Record marc4jRecord = reader.next();
records.add(marc4jRecord);
}
return records;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy