Also, be advised that current work on marc4j is happening over at Github, so for the most recent code: https://github.com/marc4j/marc4j -Tod On Aug 9, 2013, at 12:40 PM, Jonah Bull <[log in to unmask]> wrote: > There's a pretty good example included in the "samples" section of the > source ( > http://marc4j.tigris.org/source/browse/marc4j/src/org/marc4j/samples/ReadMarcExample.java?revision=1.1&view=markup > ). > > Your particular use might look something like this (not tested): > > public class MARCParser() { > > public List<String> getData(File file) { > MarcReader reader = new MarcStreamReader(new FileInputStream(file)); > List<String> data = new ArrayList<String>(); > while (reader.hasNext()) { > Record record = reader.next(); > VariableField field = record.getVariableField("856"); > data.add(field.toString()); > } > return data; > } > > } > > Hope this helps, > > Jonah > > On Fri, Aug 9, 2013 at 9:36 AM, Joshua Welker <[log in to unmask]> wrote: > >> Does anyone have a simple example of reading a MARC file using the Java >> marc4j library? The documentation is rather lackluster ( >> http://marc4j.tigris.org/doc/) and I am unable to find anything helpful >> Googling or searching discussion lists. I am wanting to do something like >> this: >> >> >> >> >> >> public class MARCParser(){ >> >> >> >> public ArrayList<String> getData(File file){ >> >> >> >> MarcReader reader = new MarcReader(file); >> >> ArrayList<String> data = new ArrayList<>; >> >> while(reader.next()){ >> >> data.add(reader.getField(“856”)); >> >> } >> >> return data; >> >> } >> >> } >> >> >> >> I figured this would be a simple enough task and have done something very >> similar with a PHP MARC library, but I am stumped here. >> >> >> >> Josh Welker >> >> Information Technology Librarian >> >> James C. Kirkpatrick Library >> >> University of Central Missouri >> >> Warrensburg, MO 64093 >> >> JCKL 2260 >> >> 660.543.8022 >>