@Test public void testWriteInt() throws Exception { final StringBuilderOutputStream stream = new StringBuilderOutputStream(); final CclOutputStreamProxy proxy = new CclOutputStreamProxy(stream, OUTPUT_BEGIN, OUTPUT_END); final String[] strings = new String[6]; strings[0] = String.format("I should not be in the output%n"); strings[1] = String.format("%s%n", OUTPUT_BEGIN); strings[2] = String.format("I am the middle content%n"); strings[3] = String.format("Second middle content%n"); strings[4] = String.format("%s%n", OUTPUT_END); strings[5] = String.format("I should not be in the output, either%n"); for (final String string : strings) for (final char currentChar : string.toCharArray()) proxy.write(currentChar); assertThat(stream.toString()).isEqualTo(strings[2] + strings[3]); proxy.close(); }
@Override public void write(final int b) throws IOException { final char bChar = (char) b; builder.append(bChar); if (bChar == '\n') { final String string = builder.toString(); if (string.contains(outputEnd)) doForward = false; else if (string.contains(outputBegin)) doForward = true; else if (doForward) { final OutputStream proxied = getProxied(); for (final char currentChar : string.toCharArray()) proxied.write(currentChar); } builder.delete(0, builder.length()); } }
CclOutputStreamProxy extends OutputStreamProxy { @Override public void write(final int b) throws IOException { final char bChar = (char) b; builder.append(bChar); if (bChar == '\n') { final String string = builder.toString(); if (string.contains(outputEnd)) doForward = false; else if (string.contains(outputBegin)) doForward = true; else if (doForward) { final OutputStream proxied = getProxied(); for (final char currentChar : string.toCharArray()) proxied.write(currentChar); } builder.delete(0, builder.length()); } } }
CclOutputStreamProxy extends OutputStreamProxy { @Override public void write(final int b) throws IOException { final char bChar = (char) b; builder.append(bChar); if (bChar == '\n') { final String string = builder.toString(); if (string.contains(outputEnd)) doForward = false; else if (string.contains(outputBegin)) doForward = true; else if (doForward) { final OutputStream proxied = getProxied(); for (final char currentChar : string.toCharArray()) proxied.write(currentChar); } builder.delete(0, builder.length()); } } CclOutputStreamProxy(final OutputStream out, final String outputBegin, final String outputEnd); }
CclOutputStreamProxy extends OutputStreamProxy { @Override public void write(final int b) throws IOException { final char bChar = (char) b; builder.append(bChar); if (bChar == '\n') { final String string = builder.toString(); if (string.contains(outputEnd)) doForward = false; else if (string.contains(outputBegin)) doForward = true; else if (doForward) { final OutputStream proxied = getProxied(); for (final char currentChar : string.toCharArray()) proxied.write(currentChar); } builder.delete(0, builder.length()); } } CclOutputStreamProxy(final OutputStream out, final String outputBegin, final String outputEnd); @Override void write(final int b); }
CclOutputStreamProxy extends OutputStreamProxy { @Override public void write(final int b) throws IOException { final char bChar = (char) b; builder.append(bChar); if (bChar == '\n') { final String string = builder.toString(); if (string.contains(outputEnd)) doForward = false; else if (string.contains(outputBegin)) doForward = true; else if (doForward) { final OutputStream proxied = getProxied(); for (final char currentChar : string.toCharArray()) proxied.write(currentChar); } builder.delete(0, builder.length()); } } CclOutputStreamProxy(final OutputStream out, final String outputBegin, final String outputEnd); @Override void write(final int b);  }