Package com.Ostermiller.util
Class LineEnds
java.lang.Object
com.Ostermiller.util.LineEnds
Stream editor to alter the line separators on text to match
that of a given platform.
More information about this class is available from ostermiller.org.
- Since:
- ostermillerutils 1.00.00
- Author:
- Stephen Ostermiller https://ostermiller.org/contact.pl?regarding=Java+Utilities
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe Windows and DOS line ending ("\r\n")static final intThe UNIX and Java line ending ("\n")static final intThe Macintosh line ending ("\r")static final intThe UNIX and Java line ending ("\n")static final intThe Macintosh line ending ("\r")static final intThe Windows and DOS line ending ("\r\n")static final intThe system line ending as determined by System.getProperty("line.separator")static final intThe UNIX and Java line ending ("\n")static final intThe Windows and DOS line ending ("\r\n")static final StringVersion number of this program -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChange the line endings on given file.static booleanChange the line endings on given file.static booleanChange the line endings on given file.static booleanChange the line endings on given file.static booleanconvert(InputStream in, OutputStream out) Change the line endings of the text on the input stream and write it to the output stream.static booleanconvert(InputStream in, OutputStream out, boolean binaryException) Change the line endings of the text on the input stream and write it to the output stream.static booleanconvert(InputStream in, OutputStream out, int style) Change the line endings of the text on the input stream and write it to the output stream.static booleanconvert(InputStream in, OutputStream out, int style, boolean binaryException) Change the line endings of the text on the input stream and write it to the output stream.static voidConverts the line ending on files, or standard input.
-
Field Details
-
version
Version number of this program- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_SYSTEM
public static final int STYLE_SYSTEMThe system line ending as determined by System.getProperty("line.separator")- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_WINDOWS
public static final int STYLE_WINDOWSThe Windows and DOS line ending ("\r\n")- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_DOS
public static final int STYLE_DOSThe Windows and DOS line ending ("\r\n")- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_RN
public static final int STYLE_RNThe Windows and DOS line ending ("\r\n")- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_UNIX
public static final int STYLE_UNIXThe UNIX and Java line ending ("\n")- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_N
public static final int STYLE_NThe UNIX and Java line ending ("\n")- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_JAVA
public static final int STYLE_JAVAThe UNIX and Java line ending ("\n")- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_MAC
public static final int STYLE_MACThe Macintosh line ending ("\r")- Since:
- ostermillerutils 1.00.00
- See Also:
-
STYLE_R
public static final int STYLE_RThe Macintosh line ending ("\r")- Since:
- ostermillerutils 1.00.00
- See Also:
-
-
Constructor Details
-
LineEnds
public LineEnds()
-
-
Method Details
-
main
Converts the line ending on files, or standard input. Run with --help argument for more information.- Parameters:
args- Command line arguments.- Since:
- ostermillerutils 1.00.00
-
convert
Change the line endings of the text on the input stream and write it to the output stream. The current system's line separator is used.- Parameters:
in- stream that contains the text which needs line number conversion.out- stream where converted text is written.- Returns:
- true if the output was modified from the input, false if it is exactly the same
- Throws:
BinaryDataException- if non-text data is encountered.IOException- if an input or output error occurs.- Since:
- ostermillerutils 1.00.00
-
convert
Change the line endings of the text on the input stream and write it to the output stream.- Parameters:
in- stream that contains the text which needs line number conversion.out- stream where converted text is written.style- line separator style.- Returns:
- true if the output was modified from the input, false if it is exactly the same
- Throws:
BinaryDataException- if non-text data is encountered.IOException- if an input or output error occurs.IllegalArgumentException- if an unknown style is requested.- Since:
- ostermillerutils 1.00.00
-
convert
public static boolean convert(InputStream in, OutputStream out, boolean binaryException) throws IOException Change the line endings of the text on the input stream and write it to the output stream. The current system's line separator is used.- Parameters:
in- stream that contains the text which needs line number conversion.out- stream where converted text is written.binaryException- throw an exception and abort the operation if binary data is encountered and binaryExcepion is false.- Returns:
- true if the output was modified from the input, false if it is exactly the same
- Throws:
BinaryDataException- if non-text data is encountered.IOException- if an input or output error occurs.- Since:
- ostermillerutils 1.00.00
-
convert
public static boolean convert(InputStream in, OutputStream out, int style, boolean binaryException) throws IOException Change the line endings of the text on the input stream and write it to the output stream.- Parameters:
in- stream that contains the text which needs line number conversion.out- stream where converted text is written.style- line separator style.binaryException- throw an exception and abort the operation if binary data is encountered and binaryExcepion is false.- Returns:
- true if the output was modified from the input, false if it is exactly the same
- Throws:
BinaryDataException- if non-text data is encountered.IOException- if an input or output error occurs.IllegalArgumentException- if an unknown style is requested.- Since:
- ostermillerutils 1.00.00
-
convert
Change the line endings on given file. The current system's line separator is used.- Parameters:
f- File to be converted.- Returns:
- true if the file was modified, false if it was already in the correct format
- Throws:
BinaryDataException- if non-text data is encountered.IOException- if an input or output error occurs.- Since:
- ostermillerutils 1.00.00
-
convert
Change the line endings on given file.- Parameters:
f- File to be converted.style- line separator style.- Returns:
- true if the file was modified, false if it was already in the correct format
- Throws:
BinaryDataException- if non-text data is encountered.IOException- if an input or output error occurs.IllegalArgumentException- if an unknown style is requested.- Since:
- ostermillerutils 1.00.00
-
convert
Change the line endings on given file. The current system's line separator is used.- Parameters:
f- File to be converted.binaryException- throw an exception and abort the operation if binary data is encountered and binaryExcepion is false.- Returns:
- true if the file was modified, false if it was already in the correct format
- Throws:
BinaryDataException- if non-text data is encountered.IOException- if an input or output error occurs.- Since:
- ostermillerutils 1.00.00
-
convert
Change the line endings on given file.- Parameters:
f- File to be converted.style- line separator style.binaryException- throw an exception and abort the operation if binary data is encountered and binaryExcepion is false.- Returns:
- true if the file was modified, false if it was already in the correct format
- Throws:
BinaryDataException- if non-text data is encountered.IOException- if an input or output error occurs.IllegalArgumentException- if an unknown style is requested.- Since:
- ostermillerutils 1.00.00
-