Class LineEndingsUtils
- java.lang.Object
-
- org.apache.maven.plugins.assembly.utils.LineEndingsUtils
-
public final class LineEndingsUtils extends java.lang.Object
Line Ending class which contains convenience methods to change line endings.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
LineEndingsUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
convertLineEndings(java.io.File source, java.io.File dest, LineEndings lineEndings, java.lang.Boolean atEndOfFile, java.lang.String encoding)
Converts the line endings of a file, writing a new file.private static java.io.BufferedReader
getBufferedReader(java.io.File source, java.lang.String encoding)
private static java.io.BufferedWriter
getBufferedWriter(java.io.File dest, java.lang.String encoding)
static LineEndings
getLineEnding(java.lang.String lineEnding)
static java.lang.String
getLineEndingCharacters(java.lang.String lineEnding)
Returns the appopriate line ending characters for the specified stylestatic java.io.InputStream
lineEndingConverter(java.io.InputStream in, LineEndings lineEndings)
Converts the line endings of a file, writing a new file.
-
-
-
Method Detail
-
convertLineEndings
public static void convertLineEndings(java.io.File source, java.io.File dest, LineEndings lineEndings, java.lang.Boolean atEndOfFile, java.lang.String encoding) throws java.io.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 nulldest
- The destination file, not nulllineEndings
- 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 fileencoding
- The encoding to use, null for platform encoding- Throws:
java.io.IOException
- .
-
getBufferedReader
private static java.io.BufferedReader getBufferedReader(java.io.File source, java.lang.String encoding) throws java.io.IOException
- Throws:
java.io.IOException
-
getBufferedWriter
private static java.io.BufferedWriter getBufferedWriter(java.io.File dest, java.lang.String encoding) throws java.io.IOException
- Throws:
java.io.IOException
-
lineEndingConverter
public static java.io.InputStream lineEndingConverter(java.io.InputStream in, LineEndings lineEndings) throws java.io.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 readerlineEndings
- 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:
java.io.IOException
-
getLineEnding
public static LineEndings getLineEnding(java.lang.String lineEnding) throws AssemblyFormattingException
- Throws:
AssemblyFormattingException
-
getLineEndingCharacters
public static java.lang.String getLineEndingCharacters(java.lang.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
-
-