|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.marc4j.MarcStreamWriter
public class MarcStreamWriter
Class for writing MARC record objects in ISO 2709 format.
The following example reads a file with MARCXML records and outputs the record set in ISO 2709 format:
InputStream input = new FileInputStream("marcxml.xml"); MarcXmlReader reader = new MarcXmlReader(input); MarcWriter writer = new MarcStreamWriter(System.out); while (reader.hasNext()) { Record record = reader.next(); writer.write(record); } writer.close();
To convert characters like for example from UCS/Unicode to MARC-8 register
a CharConverter
implementation:
InputStream input = new FileInputStream("marcxml.xml"); MarcXmlReader reader = new MarcXmlReader(input); MarcWriter writer = new MarcStreamWriter(System.out); writer.setConverter(new UnicodeToAnsel()); while (reader.hasNext()) { Record record = reader.next(); writer.write(record); } writer.close();
Constructor Summary | |
---|---|
MarcStreamWriter(OutputStream out)
Constructs an instance and creates a Writer object with
the specified output stream. |
|
MarcStreamWriter(OutputStream out,
String encoding)
Constructs an instance and creates a Writer object with
the specified output stream and character encoding. |
Method Summary | |
---|---|
void |
close()
Closes the writer. |
CharConverter |
getConverter()
Returns the character converter. |
void |
setConverter(CharConverter converter)
Sets the character converter. |
void |
write(Record record)
Writes a Record object to the writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MarcStreamWriter(OutputStream out)
Writer
object with
the specified output stream.
public MarcStreamWriter(OutputStream out, String encoding)
Writer
object with
the specified output stream and character encoding.
Method Detail |
---|
public CharConverter getConverter()
getConverter
in interface MarcWriter
public void setConverter(CharConverter converter)
setConverter
in interface MarcWriter
converter
- the character converterpublic void write(Record record)
Record
object to the writer.
write
in interface MarcWriter
record
- -
the Record
objectpublic void close()
close
in interface MarcWriter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |