Class EOLProcessor

java.lang.Object
com.sshtools.common.util.EOLProcessor

public class EOLProcessor extends Object

This class processes text data and corrects line endings according to the settings provided. Specifically you can set the input style to process so that lone \r and \n characters within a \r\n encoded file are written through without amendments (the SFTP protocol states that this must be the case when processing text files).

Author:
Lee David Painter
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    This input style instructs the conversion to strip all line ending type characters and replace with the output style line ending
    static final int
    This indicates a CR line ending style and can be used for either input or output style parameters
    static final int
     
    static final int
    This indicates a CRLF line ending combination and can be used for both input and output style parameters.
    static final int
    This indicates a single LF line ending style and can be used for either input or output style parameters
    static final int
    This indicates a MAC line ending and can be used in either the input or output style parameters
    static final int
    This output style specifies that the text will have line endings set to the current system setting.
    static final int
    This indicates a LF line ending style and can be used for either input or output style parameters
    static final int
    This indicates a CRLF line ending combination and can be used for both input and output style parameters.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EOLProcessor(int inputStyle, int outputStyle, OutputStream out)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    createInputStream(int inputStyle, int outputStyle, InputStream in)
     
    createOutputStream(int inputStyle, int outputStyle, OutputStream out)
     
    boolean
    Check to see if binary data was encountered during the encoding process
    void
    processBytes(byte[] buf, int off, int len)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TEXT_SYSTEM

      public static final int TEXT_SYSTEM
      This output style specifies that the text will have line endings set to the current system setting.
      See Also:
    • TEXT_WINDOWS

      public static final int TEXT_WINDOWS
      This indicates a CRLF line ending combination and can be used for both input and output style parameters.
      See Also:
    • TEXT_DOS

      public static final int TEXT_DOS
      This indicates a CRLF line ending combination and can be used for both input and output style parameters.
      See Also:
    • TEXT_CRLF

      public static final int TEXT_CRLF
      See Also:
    • TEXT_UNIX

      public static final int TEXT_UNIX
      This indicates a LF line ending style and can be used for either input or output style parameters
      See Also:
    • TEXT_LF

      public static final int TEXT_LF
      This indicates a single LF line ending style and can be used for either input or output style parameters
      See Also:
    • TEXT_MAC

      public static final int TEXT_MAC
      This indicates a MAC line ending and can be used in either the input or output style parameters
      See Also:
    • TEXT_CR

      public static final int TEXT_CR
      This indicates a CR line ending style and can be used for either input or output style parameters
      See Also:
    • TEXT_ALL

      public static final int TEXT_ALL
      This input style instructs the conversion to strip all line ending type characters and replace with the output style line ending
      See Also:
  • Constructor Details

  • Method Details

    • hasBinary

      public boolean hasBinary()
      Check to see if binary data was encountered during the encoding process
      Returns:
      boolean
    • close

      public void close() throws IOException
      Throws:
      IOException
    • processBytes

      public void processBytes(byte[] buf, int off, int len) throws IOException
      Parameters:
      buf - byte[]
      off - int
      len - int
      currentOut - OutputStream
      Throws:
      IOException
    • createOutputStream

      public static OutputStream createOutputStream(int inputStyle, int outputStyle, OutputStream out) throws IOException
      Throws:
      IOException
    • createInputStream

      public static InputStream createInputStream(int inputStyle, int outputStyle, InputStream in) throws IOException
      Throws:
      IOException