Class LineEndingsUtils

java.lang.Object
org.apache.maven.plugins.assembly.utils.LineEndingsUtils

public final class LineEndingsUtils extends Object
Line Ending class which contains convenience methods to change line endings.
  • Constructor Details

    • LineEndingsUtils

      private LineEndingsUtils()
  • Method Details

    • convertLineEndings

      public static void convertLineEndings(@Nonnull File source, @Nonnull File dest, LineEndings lineEndings, Boolean atEndOfFile, String encoding) throws IOException
      Converts the line endings of a file, writing a new file. The encoding of reading and writing can be specified.
      Parameters:
      source - The source file, not null
      dest - The destination file, not null
      lineEndings - This is the result of the getLineEndingChars(..) method in this utility class; the actual line-ending characters, not null.
      atEndOfFile - The end-of-file line ending, if true then the resulting file will have a new line at the end even if the input didn't have one, if false then the resulting file will have no new line at the end even if the input did have one, null to determine whether to have a new line at the end of the file based on the input file
      encoding - The encoding to use, null for platform encoding
      Throws:
      IOException - .
    • getBufferedReader

      private static BufferedReader getBufferedReader(File source, String encoding) throws IOException
      Throws:
      IOException
    • getBufferedWriter

      private static BufferedWriter getBufferedWriter(File dest, String encoding) throws IOException
      Throws:
      IOException
    • lineEndingConverter

      public static InputStream lineEndingConverter(@Nonnull InputStream in, LineEndings lineEndings) throws IOException
      Converts the line endings of a file, writing a new file. The encoding of reading and writing can be specified.
      Parameters:
      in - The source reader
      lineEndings - This is the result of the getLineEndingChars(..) method in this utility class; the actual line-ending characters, not null.
      Returns:
      an input stream that enforces a specifi line ending style
      Throws:
      IOException
    • getLineEnding

      @Nonnull public static LineEndings getLineEnding(@Nullable String lineEnding) throws AssemblyFormattingException
      Throws:
      AssemblyFormattingException
    • getLineEndingCharacters

      @Nullable public static String getLineEndingCharacters(@Nullable String lineEnding) throws AssemblyFormattingException
      Returns the appopriate line ending characters for the specified style
      Parameters:
      lineEnding - The name of the line ending style, see org.apache.maven.plugin.assembly.utils.LineEndings#valueOf
      Returns:
      The proper line ending characters
      Throws:
      AssemblyFormattingException