List of usage examples for org.apache.commons.io.output WriterOutputStream WriterOutputStream
public WriterOutputStream(Writer writer, String charsetName, int bufferSize, boolean writeImmediately)
From source file:com.magnet.tools.cli.helper.TeeFilteringOutputStream.java
/** * Creates an output stream filter built on top of the specified underlying * output stream.// ww w. j ava2 s .c om * * @param out the underlying output stream to be assigned to the field * <tt>this.out</tt> for later use, or <code>null</code> if this instance is * to be created without an underlying stream. */ public TeeFilteringOutputStream(OutputStream out, Writer writer, Renderer renderer) { super(out); filteringWriter = new FilteringWriter(writer, renderer); writerOutputStream = new WriterOutputStream(filteringWriter, "UTF-8", 256, true); }
From source file:fi.jumi.test.AppRunner.java
private JumiLauncher createLauncher() { class CustomJumiLauncherBuilder extends JumiLauncherBuilder { @Override//from w w w.j a v a2 s . c om protected ProcessStarter createProcessStarter() { return processStarter; } @Override protected NetworkServer createNetworkServer() { if (mockNetworkServer != null) { return mockNetworkServer; } return super.createNetworkServer(); } @Override protected OutputStream createDaemonOutputListener() { return new TeeOutputStream(new CloseShieldOutputStream(System.out), new WriterOutputStream(daemonOutput, daemonDefaultCharset, 1024, true)); } } JumiLauncherBuilder builder = new CustomJumiLauncherBuilder(); return builder.build(); }
From source file:ductive.console.jline.JLineInteractiveTerminal.java
@Override public OutputStream output() { return new WriterOutputStream(jline.getOutput(), Charset.forName("UTF-8"), 4096, true); }
From source file:org.codice.ddf.admin.application.service.migratable.ProfileMigratableTest.java
@Test public void testDoExport() throws Exception { final ExportMigrationContext context = Mockito.mock(ExportMigrationContext.class); final ExportMigrationEntry entry = Mockito.mock(ExportMigrationEntry.class); final StringWriter sw = new StringWriter(); Mockito.doReturn(entry).when(context).getEntry(PROFILE_PATH); Mockito.doReturn(Collections.singletonList(JFEATURE)).when(featureMigrator).exportFeatures(); Mockito.doReturn(Collections.singletonList(JBUNDLE)).when(bundleMigrator).exportBundles(); Mockito.doAnswer(AdditionalAnswers//from ww w .j av a 2 s . c o m .<Boolean, BiThrowingConsumer<MigrationReport, OutputStream, IOException>>answer(c -> { // callback the consumer c.accept(report, new WriterOutputStream(sw, Charset.defaultCharset(), 1024, true)); return true; })).when(entry) .store(Mockito.<BiThrowingConsumer<MigrationReport, OutputStream, IOException>>notNull()); migratable.doExport(context); JSONAssert.assertEquals(JSON_PROFILE_FROM_MAP, sw.toString(), true); Mockito.verify(context).getEntry(PROFILE_PATH); Mockito.verify(entry) .store(Mockito.<BiThrowingConsumer<MigrationReport, OutputStream, IOException>>notNull()); Mockito.verify(featureMigrator).exportFeatures(); Mockito.verify(bundleMigrator).exportBundles(); }
From source file:sorcer.launcher.impl.process.ForkingLauncher.java
@Override public void start() throws IOException { if (process != null) throw new IllegalStateException("This instance has already started a process"); JavaProcessBuilder bld = new JavaProcessBuilder(home.getPath()); bld.getEnvironment().putAll(environment); WriterOutputStream startMonitor = new WriterOutputStream(new SorcerOutputConsumer(sorcerListener), Charset.defaultCharset(), 1024, true); bld.setOut(getStream(new OutputStream[] { out, startMonitor }, outFile, System.out)); bld.setErr(getStream(new OutputStream[] { err, startMonitor }, errFile, System.err)); bld.setProperties(properties);//from w ww. j a v a 2 s . c o m if (debugPort != null) { bld.setDebugger(true); bld.setDebugPort(debugPort); } Collection<String> classPath = getClassPath(); bld.setClassPath(classPath); bld.getJavaAgent().put(Resolver.resolveAbsolute("org.rioproject:rio-start"), null); bld.setMainClass(MAIN_CLASS); List<String> parameters = bld.getParameters(); //-Mforce-direct enforces SorcerLauncher, so we ensure that there is no loop ForkingLauncher->Sorcer->ForkingLauncher parameters.add("-M"); parameters.add(Mode.forceDirect.paramValue); if (profile != null) { parameters.add("-P"); parameters.add(profile); } //last parameters if (configs != null) parameters.addAll(configs); process = bld.startProcess(); sorcerListener.processLaunched(process); if (!process.running()) throw new IllegalStateException("SORCER has not started properly; exit value: " + process.exitValue()); installProcessMonitor(sorcerListener, process); writePid(); }