Package org.marc4j

Examples of org.marc4j.MarcPermissiveStreamReader


    public static void convertToMARCXML( File inputFile, File outputFile, Charset inputEncoding, Charset outputEncoding ) throws Exception {
        InputStream in = new FileInputStream(inputFile);
        OutputStream out = new FileOutputStream(outputFile);

        //MarcReader reader = new MarcStreamReader(in, inputEncoding );
        MarcReader reader = new MarcPermissiveStreamReader(in,true,true,"IS05426");
        System.err.println("Using IS05426 for conversion");
        MarcXmlWriter writer = new MarcXmlWriter(out, outputEncoding, true);

        while (reader.hasNext()) {
            Record record = reader.next();

            writer.write(record);
        }
        writer.close();
    }
View Full Code Here


        try {
            OutputStream os = new FileOutputStream(tempFile);
            try {
                MarcWriter writer = new MarcXmlWriter(os, true);
               
                MarcPermissiveStreamReader reader = new MarcPermissiveStreamReader(
                    inputStream, true, true);
                while (reader.hasNext()) {
                    Record record = reader.next();
                    writer.write(record);
                }
                writer.close();
            } finally {
                try {
View Full Code Here

            try
            {
                System.err.println("Switching to input file: "+ list[curFileNum]);
                if (defaultEncoding != null)
                {
                    curFileReader = new MarcPermissiveStreamReader(new FileInputStream(list[curFileNum++]), permissive, convertToUTF8, defaultEncoding);
                }
                else
                {
                    curFileReader = new MarcPermissiveStreamReader(new FileInputStream(list[curFileNum++]), permissive, convertToUTF8);
                }
            }
            catch (FileNotFoundException e)
            {
                nextFile();
View Full Code Here

        MarcWriter patchedRecs = null;
        ErrorHandler errorHandler = new ErrorHandler();
        try
        {
            inNorm = new FileInputStream(file);
            readerNormal = new MarcPermissiveStreamReader(inNorm, false, to_utf_8);
            inPerm = new FileInputStream(file);
            readerPermissive = new MarcPermissiveStreamReader(inPerm, errorHandler, to_utf_8, "BESTGUESS");
        }
        catch (FileNotFoundException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
View Full Code Here

 
    public void testBadLeaderBytes10_11() throws Exception {
        int i = 0;
        InputStream input = getClass().getResourceAsStream(
        "resources/bad_leaders_10_11.mrc");
        MarcReader reader = new MarcPermissiveStreamReader(input, true, true);
        while (reader.hasNext()) {
            Record record = reader.next();

            assertEquals(2, record.getLeader().getIndicatorCount());
            assertEquals(2, record.getLeader().getSubfieldCodeLength());
            i++;
        }
View Full Code Here

 
      
       // This marc file has three records, but the first one
       // is too long for a marc binary record. Can we still read
       // the next two?
       MarcReader reader = new MarcPermissiveStreamReader(input, true, true);
             
       Record bad_record = reader.next();
      
       // Bad record is a total loss, don't even bother trying to read
       // it, but do we get the good records next?
       Record good_record1 = reader.next();
       ControlField good001 = good_record1.getControlNumberField();
       assertEquals(good001.getData(), "360945");
      
      
       Record good_record2 = reader.next();
       good001 = good_record2.getControlNumberField();
       assertEquals(good001.getData(), "360946");
      
    }
View Full Code Here

   
    public void testTooLongLeaderByteRead() throws Exception {
       InputStream input = getClass().getResourceAsStream(
        "resources/bad_too_long_plus_2.mrc");
      
       MarcReader reader = new MarcPermissiveStreamReader(input, true, true);
      
       //First record is the long one.
       Record weird_record = reader.next();
      
       //is it's marshal'd leader okay?
       String strLeader = weird_record.getLeader().marshal();

       // Make sure only five digits for length is used in the leader,
View Full Code Here

TOP

Related Classes of org.marc4j.MarcPermissiveStreamReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.