All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codetaco.funnel.provider.FixedLengthFileReader Maven / Gradle / Ivy

There is a newer version: 3.0.5
Show newest version
package com.codetaco.funnel.provider;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 

* FixedLengthFileReader class. *

* * @author Chris DeGreef [email protected] */ public class FixedLengthFileReader implements InputReader { static final Logger logger = LoggerFactory.getLogger(FixedLengthFileReader.class); File inputFile; RandomAccessFile reader; /** *

* Constructor for FixedLengthFileReader. *

* * @param _inputFile a {@link java.io.File} object. * @param lineSeparator an array of byte. * @throws java.io.IOException if any. */ public FixedLengthFileReader(final File _inputFile, final byte[] lineSeparator) throws IOException { open(_inputFile); } /** {@inheritDoc} */ @Override public void close() throws IOException { reader.close(); logger.debug("loaded " + inputFile.getAbsolutePath()); } /** {@inheritDoc} */ @Override public long length() throws IOException { return reader.length(); } /** {@inheritDoc} */ @Override public void open(final File _inputFile) throws IOException { inputFile = _inputFile; reader = new RandomAccessFile(_inputFile, "r"); } /** {@inheritDoc} */ @Override public long position() throws IOException { return reader.getFilePointer(); } /** {@inheritDoc} */ @Override public int read(final byte[] row) throws IOException { return reader.read(row); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy