public class PlatformLineWriter
extends Writer
A buffered writer that gobbles any \r characters and replaces every \n with a platform specific newline. In many places Groovy normalises streams to only have \n characters but when creating files that must be used by other platform-aware tools, you sometimes want the newlines to match what the platform expects.
| Constructor and description |
|---|
PlatformLineWriter(Writer out)Creates a writer that normalizes line endings for the platform. |
PlatformLineWriter(Writer out, int sz)Creates a writer that normalizes line endings for the platform. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
close()Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.
|
|
public void |
flush()Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
|
|
public void |
write(char[] cbuf, int off, int len)Writes characters while converting line endings to the platform format. |
Creates a writer that normalizes line endings for the platform.
out - the underlying writerCreates a writer that normalizes line endings for the platform.
out - the underlying writersz - the output buffer sizeCloses the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.
Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
Writes characters while converting line endings to the platform format.
cbuf - the source bufferoff - the buffer offsetlen - the number of characters to writeCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.