×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
All my java stuff on the i run in batch so I have experimented a bit
with how to approach the fact that the linewidth is 132 characters or
something like that and no more - everything written after the 132'th
column vanishes.
I ended up writing this small class which I call ONCE as the first thing
in the program (even before the logging system gets initialized). It
works by putting a wrapper around both System.out and System.err which
counts where you are on the current line and outputs a newline and
indents when the line gets too long. The value of 127 in width and 3 in
indent works well viewing with the client access emulator.
/**
* Set up System.out and System.err to be wrapped and indented to be
* readable even on the AS/400 QPRINT device at 132x27 (text written
over
* this edge is truncated and discarded).
*
* <br/>
*
* It is recommended that this is the first line called in the main
class.
* If logging is active for that class, do NOT initialize it in the
field
* definition, but do it after this call "inline" in main().
*/
public static void wrapAndIndentOnAS400() {
wrapAndIndent(127, 3);
}
private static void wrapAndIndent(int wrapColumn, int indent) {
err = System.err;
out = System.out;
System.setErr(new WrapAndIndentPrintStream(err, wrapColumn,
indent).getStream());
System.setOut(new WrapAndIndentPrintStream(out, wrapColumn,
indent).getStream());
}
}
===
public class WrapAndIndentPrintStream {
protected static final int BEFORE_COLUMN_ZERO = -1;
private int indent;
private PrintStream stream;
private int wrapColumn;
private PrintStream wrappedStream;
/**
* @param wrappedStream
* @param wrapColumn - first column is column 0.
* @param indent
*/
public WrapAndIndentPrintStream(PrintStream wrappedStream, int
wrapColumn, int indent) {
this.wrappedStream = wrappedStream;
this.wrapColumn = wrapColumn;
this.indent = indent;
}
public PrintStream getStream() {
if (stream == null) {
stream = new PrintStream(new OutputStream() {
// Next char will go in 0
int currentColumn = BEFORE_COLUMN_ZERO;
public void write(int b) {
wrappedStream.write(b);
currentColumn = currentColumn + 1;
if (b == '\n') {
currentColumn = BEFORE_COLUMN_ZERO;
} else if (currentColumn >= wrapColumn) {
wrappedStream.write('\n');
currentColumn = BEFORE_COLUMN_ZERO;
for (int i = 0; i < indent; i++) {
if (i == 0) {
wrappedStream.write('+');
} else {
wrappedStream.write(' ');
}
currentColumn = currentColumn + 1;
}
}
}
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.